diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/forms/AutocompleteTextField.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/forms/AutocompleteTextField.kt index 619d302..bf92d3d 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/forms/AutocompleteTextField.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/forms/AutocompleteTextField.kt @@ -43,13 +43,13 @@ fun AutocompleteTextField( val coroutineScope = rememberCoroutineScope() - fun fetchSuggestionsAsync() { + fun fetchSuggestionsAsync(query: String) { suggestionsFetchJob?.cancel() suggestionsFetchJob = coroutineScope.launch { isLoading = true - suggestions = fetchSuggestions(value) + suggestions = fetchSuggestions(query) isLoading = false if (expanded == false && suggestions.isNotEmpty()) { @@ -67,7 +67,7 @@ fun AutocompleteTextField( onEnteredTextChanged(query) if (query.length >= minTextLengthForSearch) { - fetchSuggestionsAsync() + fetchSuggestionsAsync(query) } else { suggestions = emptyList() expanded = false @@ -75,7 +75,7 @@ fun AutocompleteTextField( }, modifier = Modifier.fillMaxWidth().focusRequester(textFieldFocus).onFocusChanged { focusState -> if (focusState.isFocused && minTextLengthForSearch == 0) { - fetchSuggestionsAsync() + fetchSuggestionsAsync(value) } }, label = { Text(label) },