Closed 456634 closed 10 months ago
Made reproducible sample project here: https://github.com/dima-avdeev-jb/issue-4077-textfield-dropdown/tree/613dc083c5e624e1453d434cc0f8b9a29eb3dbd1
This behavior is also reproduced on Android as well. TextField looses focus - that's why it happends
I don't know exactly is it bug or not. Because behavior to change focus is desired. Can you please create an Issue with the same description in Android JetPack Compose Issue tracker https://issuetracker.google.com/issues/new?component=612128
And link this issue here. First of all Android team should determin how this should behave. Thanks!
As a workaround pay attention to this project: https://github.com/MaheshaGubbi/mgv_auto_search_textfield/blob/master/app/src/main/java/com/mgvautosearchtextfield/MainActivity.kt
This sample don't loose focus of TextField while expanding
Hi Dima, thanks for your quick response. I would like to report it to Google, but currently, I don't have an account. I'm sorry.
I understand your point, and I agree that the focus should switch. However, I think there should be a way to regain focus. I have already tried this with FocusRequester()
, but unfortunately without success.
You can avoid the dropdown menu from grabbing the focus by using DropdownMenu
instead of ExposedDropdownMenu
and passing it PopupProperties(focusable = false)
, e.g.:
DropdownMenu(
expanded = expanded,
onDismissRequest = onDismissRequest,
modifier = modifier.exposedDropdownSize(),
properties = PopupProperties(focusable = false),
) {
// content here
}
@456634 If @m-sasha describe a proper way for you. Can we close this Issue? I will close it - but feel free to message us with request to reopen
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.
When attempting to type into the text field while the dropdown menu is open, the
onValueChange()
is not triggered.Affected platforms
Versions