If I click on a `TextField` at the bottom of the s...
# compose
a
If I click on a
TextField
at the bottom of the screen in a
LazyColumn
the keyboard popups up momentarily, and then quickly disappears: you can't then enter input. Is this a known issue? Code in 🧵.
Copy code
setContent {
  val items = mutableListOf<Int>().apply {
    (1..100).forEach { add(it) }
  }
  LazyColumn {
    items(items) { item ->
      TextField("$item", {})
    }
  }
}
It's fine if you click on a
TextField
at the top of the screen. But if you click on one at the bottom you get the aforementioned behaviour. This happens in Compose 1.3.0 on the emulator and on a real device.
m
I have a very similar issue with two text edit boxes, which are XML-based. It only happens for Android 12 users and these edit boxes haven’t been touched since 2019 so it’s really a mystery. We brought it to Google but they were unable to repro the issue so they couldn’t help. 😕 All that to say, this may not be a compose-related issue.
Have you tried your code on an Android 11 emulator to see if it works?
a
I've tried it on Android 6 and Android 11
The Android 11 is a Samsung phone. Android 6 is an emulator.
I'll see if stackoverflow bares any fruit and will let you know.
m
Oh I see, maybe the issue is different then if it’s happening on 6 and 11 as well. Not sure if this will help but Google did send me this file and directions: https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/j[…]com/android/internal/inputmethod/SoftInputShowHideReason.java
You can check the log by executing
adb shell dumpsys input_method
command after enabling the developer option.
You need to find SoftInputShowHideHistory entries to find who is trying to show/hide the software keyboard and how. The meanings of reason fields can be found in this file.
z
You probably already know this, but its likely happening due to the TextField leaving the composition as a result of the keyboard showing up. If you havent tried it already,
adjustResize
in
android:windowSoftInputMode
might help. I think the list can automatically scroll to keep the focused field in view if you provide stable keys for the items as well.
z
a
I changed the input method to
adjustPan
and I could enter text at the bottom of the screen, and the list scrolled to the
TextField