https://kotlinlang.org logo
#compose
Title
# compose
a

adjpd

08/21/2022, 10:48 PM
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

Mia Clapham

08/21/2022, 11:06 PM
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

adjpd

08/21/2022, 11:24 PM
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

Mia Clapham

08/21/2022, 11:33 PM
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

Zoltan Demant

08/22/2022, 2:45 AM
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

Zach Klippenstein (he/him) [MOD]

08/22/2022, 1:32 PM
a

adjpd

08/22/2022, 4:13 PM
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
2 Views