Focusing recipient name text field by default (but the same does not work for AddAccountDialog bank text field

This commit is contained in:
dankito 2024-09-09 20:19:21 +02:00
parent 131d08cc93
commit b1b84ce8f6
2 changed files with 6 additions and 2 deletions

View File

@ -72,6 +72,8 @@ fun TransferMoneyDialog(
var isTransferringMoney by remember { mutableStateOf(false) }
val recipientNameFocus = remember { FocusRequester() }
val amountFocus = remember { FocusRequester() }
val verticalSpace = 8.dp
@ -147,6 +149,7 @@ fun TransferMoneyDialog(
recipientName,
dropdownMaxHeight = 350.dp,
minTextLengthForSearch = 0,
textFieldFocus = recipientNameFocus,
onEnteredTextChanged = { recipientName = it },
getItemTitle = { suggestion -> suggestion.name },
onSelectedItemChanged = {
@ -269,6 +272,8 @@ 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()
}
}
}

View File

@ -28,6 +28,7 @@ fun <T> AutocompleteTextField(
getItemTitle: ((T) -> String)? = null,
dropdownMaxHeight: Dp = 400.dp,
modifier: Modifier = Modifier,
textFieldFocus: FocusRequester = remember { FocusRequester() },
keyboardOptions: KeyboardOptions = KeyboardOptions.Default,
leadingIcon: @Composable (() -> Unit)? = null,
fetchSuggestions: suspend (query: String) -> Collection<T> = { emptyList() },
@ -38,8 +39,6 @@ fun <T> AutocompleteTextField(
var suggestions by remember { mutableStateOf<Collection<T>>(emptyList()) }
var suggestionsFetchJob: Job? = null
val textFieldFocus = remember { FocusRequester() }
val coroutineScope = rememberCoroutineScope()