I have a TextField
for which I want to programmatically controll whether it's enabled.
When I disable the TextField, I want the focus to be cleared and the keyboard to be hidden.
The following is a minimum example of the behavior I want:
@Composable
fun Content() {
// styling omitted
Column {
var enabled by remember { mutableStateOf(true) }
val (text, setText) = remember { mutableStateOf("Hello World") }
TextField(text, setText, enabled = enabled)
Button(onClick = { enabled = !enabled }) { Text(if (enabled) "disable" else "enable") }
}
}
My Problem is that text decorations placed by the keyboard (e.g. underlining the current word) stay when the TextField is disabled. How can I fix that? Note that I don't just want to remove the text decorations while the TextField is focussed (I believe this could be achieved by setting the keyboard style to password).
Current Word is underlined while typing - that's ok
Text underline stays when text field is disabled and keyboard is removed - that's not ok