From 1d7ab859be7d852279c441e02933adab64018e24 Mon Sep 17 00:00:00 2001 From: Khushboo Mehta Date: Mon, 15 Jul 2024 19:09:21 +0200 Subject: [PATCH] fix(!desktop/wallet): Swap Modal doesn't have cursor visible when launched fixes #15417 --- storybook/qmlTests/tests/tst_SwapModal.qml | 21 ++++++++++++++++++- .../Wallet/panels/SwapInputPanel.qml | 5 ----- .../Wallet/popups/swap/SwapModal.qml | 15 +++++++++++-- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/storybook/qmlTests/tests/tst_SwapModal.qml b/storybook/qmlTests/tests/tst_SwapModal.qml index 4f32bea8af..98be5c4964 100644 --- a/storybook/qmlTests/tests/tst_SwapModal.qml +++ b/storybook/qmlTests/tests/tst_SwapModal.qml @@ -326,8 +326,14 @@ Item { // Launch popup launchAndVerfyModal() - for(let i =0; i< swapAdaptor.nonWatchAccounts.count; i++) { + const payPanel = findChild(controlUnderTest, "payPanel") + verify(!!payPanel) + const amountToSendInput = findChild(payPanel, "amountToSendInput") + verify(!!amountToSendInput) + verify(amountToSendInput.input.input.edit.activeFocus) + verify(amountToSendInput.input.input.edit.cursorVisible) + for(let i =0; i< swapAdaptor.nonWatchAccounts.count; i++) { // launch account selection dropdown const accountsModalHeader = getAndVerifyAccountsModalHeader() launchAccountSelectionPopup(accountsModalHeader) @@ -356,6 +362,9 @@ Item { const headerContentItemEmoji = findChild(accountsModalHeader, "assetContent") verify(!!headerContentItemEmoji) compare(headerContentItemEmoji.asset.emoji, swapAdaptor.nonWatchAccounts.get(i).emoji) + + verify(amountToSendInput.input.input.edit.activeFocus) + verify(amountToSendInput.input.input.edit.cursorVisible) } closeAndVerfyModal() } @@ -364,6 +373,13 @@ Item { // Launch popup launchAndVerfyModal() + const payPanel = findChild(controlUnderTest, "payPanel") + verify(!!payPanel) + const amountToSendInput = findChild(payPanel, "amountToSendInput") + verify(!!amountToSendInput) + verify(amountToSendInput.input.input.edit.activeFocus) + verify(amountToSendInput.input.input.edit.cursorVisible) + // get network comboBox const networkComboBox = findChild(controlUnderTest, "networkFilter") verify(!!networkComboBox) @@ -396,6 +412,9 @@ Item { const networkComboIcon = findChild(networkComboBox.control.contentItem, "contentItemIcon") verify(!!networkComboIcon) verify(networkComboIcon.asset.name.includes(root.swapAdaptor.filteredFlatNetworksModel.get(i).iconUrl)) + + verify(amountToSendInput.input.input.edit.activeFocus) + verify(amountToSendInput.input.input.edit.cursorVisible) } } networkComboBox.control.popup.close() diff --git a/ui/app/AppLayouts/Wallet/panels/SwapInputPanel.qml b/ui/app/AppLayouts/Wallet/panels/SwapInputPanel.qml index 5ded9029f2..ca3710f1ee 100644 --- a/ui/app/AppLayouts/Wallet/panels/SwapInputPanel.qml +++ b/ui/app/AppLayouts/Wallet/panels/SwapInputPanel.qml @@ -79,11 +79,6 @@ Control { implicitWidth: 492 implicitHeight: 131 - Component.onCompleted: { - if (root.swapSide === SwapInputPanel.SwapSide.Pay) - amountToSendInput.input.forceActiveFocus() - } - QtObject { id: d diff --git a/ui/app/AppLayouts/Wallet/popups/swap/SwapModal.qml b/ui/app/AppLayouts/Wallet/popups/swap/SwapModal.qml index 5f6d89651d..150b959d16 100644 --- a/ui/app/AppLayouts/Wallet/popups/swap/SwapModal.qml +++ b/ui/app/AppLayouts/Wallet/popups/swap/SwapModal.qml @@ -90,6 +90,7 @@ StatusDialog { NumberAnimation { duration: 1000; easing.type: Easing.OutExpo; alwaysRunToEnd: true} } + onOpened: payPanel.forceActiveFocus() onClosed: root.swapAdaptor.reset() header: Item { @@ -107,6 +108,7 @@ StatusDialog { root.swapInputParamsForm.selectedAccountAddress = currentAccountAddress } } + control.popup.onClosed: payPanel.forceActiveFocus() } } @@ -176,6 +178,7 @@ StatusDialog { } } } + payPanel.forceActiveFocus() } } } @@ -211,7 +214,11 @@ StatusDialog { swapSide: SwapInputPanel.SwapSide.Pay swapExchangeButtonWidth: swapExchangeButton.width - onSelectedHoldingIdChanged: root.swapInputParamsForm.fromTokensKey = selectedHoldingId + onSelectedHoldingIdChanged: { + if(!!selectedHoldingId) { + root.swapInputParamsForm.fromTokensKey = selectedHoldingId + } + } onRawValueChanged: { if(root.swapInputParamsForm.fromTokensKey === selectedHoldingId) { const amount = !tokenAmount && value === 0 ? "" : @@ -250,7 +257,11 @@ StatusDialog { mainInputLoading: root.swapAdaptor.swapProposalLoading bottomTextLoading: root.swapAdaptor.swapProposalLoading - onSelectedHoldingIdChanged: root.swapInputParamsForm.toTokenKey = selectedHoldingId + onSelectedHoldingIdChanged: { + if(!!selectedHoldingId) { + root.swapInputParamsForm.toTokenKey = selectedHoldingId + } + } /* TODO: keep this input as disabled until the work for adding a param to handle to and from tokens inputed is supported by backend under