diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/dialogs/TransferMoneyDialog.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/dialogs/TransferMoneyDialog.kt index e2eb03f..0fa2d0a 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/dialogs/TransferMoneyDialog.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/dialogs/TransferMoneyDialog.kt @@ -77,6 +77,8 @@ fun TransferMoneyDialog( val amountFocus = remember { FocusRequester() } + val referenceFocus = remember { FocusRequester() } + val verticalSpace = 8.dp var isInitialized by remember { mutableStateOf(false) } @@ -211,6 +213,7 @@ fun TransferMoneyDialog( if (it != null) { amount = it.amount.toString() paymentReference = it.reference + referenceFocus.requestFocus() } }, fetchSuggestions = { query -> recipientFinder.findAmountPaymentDataForIban(recipientAccountIdentifier, query) } @@ -228,8 +231,9 @@ fun TransferMoneyDialog( AutocompleteTextField( "Verwendungszweck (optional)", paymentReference, - dropdownMaxHeight = 175.dp, // when showing more items than on Android autocomplete dropdown covers soft keybaord + dropdownMaxHeight = 175.dp, // when showing more items than on Android autocomplete dropdown covers soft keyboard minTextLengthForSearch = 1, + modifier = Modifier.focusRequester(referenceFocus), getItemTitle = { suggestion -> suggestion.reference }, onEnteredTextChanged = { paymentReference = it }, onSelectedItemChanged = { paymentReference = it?.reference ?: "" }, @@ -271,7 +275,13 @@ fun TransferMoneyDialog( coroutineScope.launch { recipientFinder.updateData(bankingService.getAllAccountTransactions()) // only a bit problematic: if in the meantime new transactions are retrieved, then RecipientFinder doesn't contain the newly retrieved transactions - recipientNameFocus.requestFocus() + if (data.recipientName.isNullOrBlank()) { + recipientNameFocus.requestFocus() + } else if (data.amount == null) { + amountFocus.requestFocus() + } else { + referenceFocus.requestFocus() + } } } }