Skip to content

Commit 5021838

Browse files
uqlidijohnny9
andcommitted
qml: close console autocomplete when leaving Console tab
Co-authored-by: johnny9 <johnny9dev@pm.me>
1 parent c4be0bd commit 5021838

3 files changed

Lines changed: 29 additions & 0 deletions

File tree

qml/pages/node/CommandConsole.qml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ Page {
3030
property string commandDraft: ""
3131
property string searchDraft: ""
3232

33+
// True while this view's tab is the selected one. As a persistent StackLayout
34+
// child, the console is never destroyed on tab changes, and its autocomplete
35+
// Popup renders in the window overlay layer, so it is not hidden along with
36+
// the view. The embedder binds this to its tab's checked state; when the tab
37+
// is left, dismiss the popup so it cannot linger over the newly selected tab.
38+
property bool tabActive: true
39+
onTabActiveChanged: if (!tabActive) autocompletePopup.close()
40+
3341
function _pushPalette() {
3442
rpcConsoleModel.requestColor = consoleRequestColor
3543
rpcConsoleModel.replyColor = consoleReplyColor

qml/pages/wallet/DesktopWallets.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ Page {
346346
}
347347
CommandConsole {
348348
showHeader: false
349+
tabActive: consoleTabButton.checked
349350
walletName: walletController.isWalletLoaded && walletController.selectedWallet
350351
? walletController.selectedWallet.name
351352
: ""

test/qml/tst_desktopwallets.qml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,26 @@ TestCase {
9797
compare(tabs[3].iconSize, 30)
9898
}
9999

100+
function test_console_autocomplete_closes_when_switching_tabs() {
101+
const page = createDesktopWallets()
102+
const consoleTab = findChild(page, "consoleTabButton")
103+
const activityTab = findChild(page, "activityTabButton")
104+
const popup = findChild(page, "consoleAutocompletePopup")
105+
106+
verify(consoleTab !== null)
107+
verify(activityTab !== null)
108+
verify(popup !== null)
109+
110+
consoleTab.checked = true
111+
tryCompare(consoleTab, "checked", true)
112+
popup.open()
113+
tryCompare(popup, "visible", true)
114+
115+
activityTab.checked = true
116+
tryCompare(activityTab, "checked", true)
117+
tryCompare(popup, "visible", false)
118+
}
119+
100120
function test_receive_options_view_address_history_opens_settings_address_stack() {
101121
const page = createDesktopWallets()
102122
const receiveTab = findChild(page, "receiveTabButton")

0 commit comments

Comments
 (0)