[iOS] LazyColumn with imePadding and TextField scrolls incorrectly when keyboard is shown
Describe the bug
When a TextField inside LazyColumn with Modifier.imePadding receives focus and the keyboard is displayed, the column is placed incorrectly, sometimes leaving a gap between itself and the keyboard.
Affected platforms
- iOS
Versions
- Kotlin version*: 1.9.21
- Compose Multiplatform version*: 1.5.11
To Reproduce
@Composable
fun IosApp() {
MaterialTheme {
LazyColumn(Modifier.imePadding().fillMaxSize().background(Color.Yellow)) {
items(10) {
ListItem()
}
}
}
}
@Composable
private fun ListItem() {
var text by remember { mutableStateOf("") }
TextField(
value = text,
onValueChange = { text = it },
modifier = Modifier.fillMaxWidth().padding(vertical = 40.dp, horizontal = 20.dp)
)
}
Screenshots
https://github.com/JetBrains/compose-multiplatform/assets/5230206/9d7f03e6-8b47-4b10-8165-94d149e0c5e5
This has already been reported in https://github.com/JetBrains/compose-multiplatform/issues/3621, but that reports several bugs in one ticket, and this has a more specific reproducer.
For anyone that runs into this, setting onFocusBehavior = OnFocusBehavior.DoNothing in the ComposeUIViewController fixed this for me. Found it in this merge.
For anyone that runs into this, setting
onFocusBehavior = OnFocusBehavior.DoNothingin theComposeUIViewControllerfixed this for me. Found it in this merge.
Thank you so much!!! I spent literally 2 days trying to understand whats going on.