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
This commit is contained in:
Alex Jbanca 2024-07-17 10:53:04 +03:00 committed by Alex Jbanca
parent 5fc3b37fbd
commit 663fd91425
1 changed files with 14 additions and 0 deletions

View File

@ -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()
}
}