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

Kata

05/13/2022, 1:34 PM
I am using
BasicTextField
when I clear the focus with
focusRequester.freeFocus()
the keyboard disappears but the cursor is still inside the TextField. Is there a good way to make it disappear once the view is not focused?
Found the solution, I need both
Copy code
focusRequester.freeFocus()
focusManager.clearFocus()
z

Zach Klippenstein (he/him) [MOD]

05/13/2022, 4:41 PM
@Ralston Da Silva Is the keyboard disappearing on freeFocus expected behavior? IIUC it should move the field out of the captured state but leave it focused, in which case the keyboard should remain I would think.
r

Ralston Da Silva

05/13/2022, 4:50 PM
I think for this use case you only need clearFocus()
FocusRequester.captureFocus() and FocusRequester.freeFocus() go together
To Zach's question, freeFocus() should be a no-op if captureFocus() wasn't called before. This looks like a bug
👍🏻 1
z

Zach Klippenstein (he/him) [MOD]

05/13/2022, 4:56 PM
k

Kata

05/13/2022, 6:25 PM
I found that some hide keyboard logic was still left on the fragement level and this is why the focus remained, but the keyboard disappeared. I also called capturFocus so the freeFocus is needed.
8 Views