From 663fd914252cbac2e2e85c6a232c71edb42050ec Mon Sep 17 00:00:00 2001 From: Alex Jbanca Date: Wed, 17 Jul 2024 10:53:04 +0300 Subject: [PATCH] chore(AccountSelector): Default to the first item in the account selector when the pre-selected address is not found in the model There are cases when the AccountSelector can receive invalid address in the input API. In this case we'll default to the first selected item --- ui/imports/shared/controls/AccountSelector.qml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ui/imports/shared/controls/AccountSelector.qml b/ui/imports/shared/controls/AccountSelector.qml index 10be7606f2..4cc4585b99 100644 --- a/ui/imports/shared/controls/AccountSelector.qml +++ b/ui/imports/shared/controls/AccountSelector.qml @@ -122,6 +122,11 @@ StatusComboBox { sourceModel: root.model ?? null key: "address" value: d.currentAccountSelection + onAvailableChanged: { + if (!available) { + d.resetSelection() + } + } } QtObject { @@ -131,6 +136,15 @@ StatusComboBox { Binding on currentAccountSelection { value: root.selectedAddress || root.currentValue } + + function resetSelection() { + currentAccountSelection = "" + } + } + + Component.onCompleted: { + if (!selectedEntry.available) + d.resetSelection() } }