compose-multiplatform icon indicating copy to clipboard operation
compose-multiplatform copied to clipboard

[iOS] LazyColumn with imePadding and TextField scrolls incorrectly when keyboard is shown

Open m-sasha opened this issue 2 years ago • 1 comments

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.

m-sasha avatar Dec 08 '23 05:12 m-sasha

For anyone that runs into this, setting onFocusBehavior = OnFocusBehavior.DoNothing in the ComposeUIViewController fixed this for me. Found it in this merge.

mortphose avatar Feb 02 '24 14:02 mortphose

For anyone that runs into this, setting onFocusBehavior = OnFocusBehavior.DoNothing in the ComposeUIViewController fixed this for me. Found it in this merge.

Thank you so much!!! I spent literally 2 days trying to understand whats going on.

Krobys avatar Mar 27 '24 12:03 Krobys