zt
12/21/2022, 4:58 AM.clickable {
coroutineScope.launch {
viewModel.selectSuggestion(suggestion)
focusManager.clearFocus()
}
}
TextField(
value = viewModel.textFieldValue,
onValueChange = viewModel::textFieldValueChange
)
var textFieldValue by mutableStateOf(TextFieldValue())
private set
fun selectSuggestion(suggestion: String) {
textFieldValue = TextFieldValue(
text = suggestion,
selection = TextRange(suggestion.length)
)
}
fun textFieldValueChange(value: TextFieldValue) {
textFieldValue = value
}
Zach Klippenstein (he/him) [MOD]
12/22/2022, 12:42 AMwithFrameNanos
would probably work too. That means there’s probably a race condition in the field where a focus change causes the old internal state to be used instead of the newly composed value. Please file a bug - might not be fixed in the current field but there are a bunch of these kinds of bugs in the current impl that we’re hoping to fix as we rewrite the TextField impl.zt
12/22/2022, 12:43 AM