Hi, I am developing an android app using jetpack compose. In it I am using the foundation BasicTextField for the input field. While testing the app on different devices, I have observed a peculiar issue-
When I insert the first character, it shows on the screen (as expected). However when I insert the second character, the first character gets replaced by the second character.
I have investigated this issue and found that-
- The component is working fine for all the devices except samsung and that also when using samsung keyboard.
- If we use another keyboard like gboard on samsung device, the issue is not observed.
- Further more if we switch off the predective text for samsung keyboard, then also the issue is not observed and it works as expected.
- Also in my app, I am changing the ImeAction dynamically, so when this change is triggered, then the input text is cleared and the issue is observed. If I provide a static ImeAction then this issue is not observed.
Here is the code snippet which I am using-
var value by remember { mutableStateOf("") }
BasicTextField(
value = value,
onValueChange = {
value = it
},
keyboardOptions = KeyboardOptions.Default.copy(
imeAction = if(value.isEmpty()) ImeAction.Next else ImeAction.Done,
),
)
I am also facing this issue if I use Material’s TextField composable.
I have search the web for the issue but could’nt find any leads. Any help on this would be greatly appreciated. Thanks in advance.