Ime action not being updated on TextField switch inside Jetpack Compose

179 Views Asked by At

I have multiple TextFields and with the ime action Next the user can jump until the last one which has the ime action Done. What I have noticed is that, even the cursor is inside the last TextField, the ime action is not being updated. It still says Next and stays like this until I type something into the TextField (the action behind the button is correct, even when I click on the "Next" the "Done" action of the last TextField is being executed). In order to reproduce this issue it is enough to have two TextFields and by tapping inside them the ime action should be updated, but it is not, it always stays at the value from the TextField from which the keyboard initially popped up)

    TextField(
        value = text1.value,
        onValueChange = {
            text1.value = it
        },
        keyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Next),
        keyboardActions = KeyboardActions(
            onNext = {
                Log.d("Screen", "NEXT")
            }
        )
    )
    TextField(
        value = text2.value,
        onValueChange = {
            text2.value = it
        },
        keyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Done),
        keyboardActions = KeyboardActions(
            onDone = {
                Log.d("Screen", "DONE")
            }
        )
    )

Did someone notice this issue too or has a solution to it? Also tried wrapping the KeyboardOptions inside a mutableState and update its value depending on the currently focused item (to force a recomposition) but it did not help.

0

There are 0 best solutions below