Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
m-sasha opened this issue Dec 8, 2023 · 3 comments · Fixed by JetBrains/compose-multiplatform-core#1199
Assignees
Labels
bug Something isn't working ios reproduced

Comments

@m-sasha
Copy link
Contributor

m-sasha commented Dec 8, 2023

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

Simulator.Screen.Recording.-.iPhone.15.Pro.-.2023-12-08.at.07.43.40.mp4

This has already been reported in #3621, but that reports several bugs in one ticket, and this has a more specific reproducer.

@mortphose
Copy link

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

@Krobys
Copy link

Krobys commented Mar 27, 2024

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.

@ASalavei ASalavei self-assigned this Apr 5, 2024
ASalavei added a commit to JetBrains/compose-multiplatform-core that referenced this issue Apr 15, 2024
## Proposed Changes
- Extract keyboard listener to a separate class object.
- Use keyboard observer to handle scene offset for each compose layer
  
  Fixes JetBrains/compose-multiplatform#4016
  Fixes JetBrains/compose-multiplatform#4618
@okushnikov
Copy link

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ios reproduced
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants