I've a textfield with 50 characters limit, when i ...
# compose
d
I've a textfield with 50 characters limit, when i keep typing the textfield clears itself and is reset. I've debugged the issue and it's the
onValueChange
callback that is coming with a single character
Copy code
@Composable
fun ReproduceBug() {
    var value by remember { mutableStateOf(TextFieldValue()) }
    Column {
        Text(text = "Write on this textfield over 50 characters")
        TextField(
            value = value,
            onValueChange = {
                if (it.text.length <= 50) {
                    value = it
                }
            },
        )
        Text(text = "Characters: ${value.text.length}")
    }
}
I've created a bug report https://issuetracker.google.com/issues/193896392