JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
16.21k stars 1.17k forks source link

Incorrect `imePadding` and high cpu usage when repeatedly opening and closing `Keyboard` on iOS #4506

Closed robxyy closed 1 month ago

robxyy commented 7 months ago

Describe the bug Incorrect imePadding and high cpu usage when repeatedly opening and closing Keyboard on iOS

Affected platforms

Versions

To Reproduce Steps and/or the code snippet to reproduce the behavior:

@Composable
fun App() {
  MaterialTheme(
    colors = darkColors()
  ) {
    Surface {
      Column(
        Modifier.statusBarsPadding().fillMaxSize(),
        verticalArrangement = Arrangement.Center
      ) {
        val focusManager = LocalFocusManager.current
        val imePadding = WindowInsets.ime.asPaddingValues()

        TextField("", {}, Modifier.fillMaxWidth())
        TextField("Hello World!", {}, Modifier.fillMaxWidth())
        Text(imePadding.toString())

        LazyColumn(
          Modifier.pointerInput(Unit) {
            detectTapGestures {
              focusManager.clearFocus(true)
            }
          }.imePadding()
        ) {
          items(100) {
            Text("Hello World!", Modifier.fillParentMaxWidth())
          }
        }
      }
    }
  }
}

Expected behavior Normal cpu usage and correct imePadding

Screenshots

https://github.com/JetBrains/compose-multiplatform/assets/9105106/73f3b7ab-bef7-4316-adb4-11b5332cbb8b

image
okushnikov commented 2 months ago

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