My TextField gets hidden behind Keyboard. How do I...
# compose
c
My TextField gets hidden behind Keyboard. How do I avoid it? I am able to solve it by below snippet added to my activity.
Copy code
android:windowSoftInputMode="adjustResize"
But if my
TextField
is inside a
ModalBottomSheet
, then this doesn't work. What should be the fix for this?
s
Did you try the following?
Copy code
val coroutineScope = rememberCoroutineScope()
val bringIntoViewRequester = remember { BringIntoViewRequester() }

BasicTextField(
    modifier = Modifier
        .bringIntoViewRequester(bringIntoViewRequester)
        .onFocusEvent { state ->
              if (state.hasFocus || state.isFocused) {
                  coroutineScope.launch {
                      delay(300) // important!
                      bringIntoViewRequester.bringIntoView()
                  }
              }
          }
)
K 1
c
It works if you click on a
TextField
and keyboard pops up. But ones keybaord is already up and you start clicking on
ImeAction.Next
button, the `TextField`s present behind the keyboard stays there and doesn't come to visible window.
s
Uhm I was in this exact scenario, but it worked; are you using accompanist insets by chance?
z
This should be fixed in the next release, unless your text field is in a lazy list
💯 1
🦜 1
K 1
c
Thanks for the update @Zach Klippenstein (he/him) [MOD] Will wait for the next release.