Has the default behaviors of ImeActions in Text wo...
# compose
a
Has the default behaviors of ImeActions in Text worked for anyone? Seems it has never worked since compose-dev. Still not working in beta01
specifically, ImeAction.Next isn’t going to the next focusable
r
Hey I think you need to request focus from the next text field in onNext of the first text field
Copy code
val lastNameFocusRequest = remember { FocusRequester() }
                    val focusManager = LocalFocusManager.current

                    TextField(
                        ..
                        keyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Next),
                        keyboardActions = KeyboardActions(onNext = { lastNameFocusRequest.requestFocus() }),
                        modifier = Modifier.weight(0.33f)
                    )
                    TextField(
                        ...
                        keyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Done),
                        keyboardActions = KeyboardActions(
                            onDone = {
                                focusManager.clearFocus()
                                currentPage = getNextState(currentPage)
                            }
                        ),
                        modifier = Modifier
                            .weight(0.33f)
                            .focusRequester(lastNameFocusRequest)
                    )
a
Yeah, I do that. But I shouldn’t have to I think. See this documentation in KeyboardActions
thanks for the example btw!
🙌 1
r
Ooh! It didn't work for me without this. How does the system know about the focus traversal order though? Does the parent need to communicate to the system somehow?
a
I can only guess that probably compose is able to traverse through the composable hierarchy and find out the next focus. But I think it may not be implemented yet…
j
As far as i understand, automatically focusing the next textfield is not expected behaviour for now, see https://issuetracker.google.com/issues/165676636
a
status is won’t fix, not reproducible. 🤔
but good find, it might be a regression
z
I would just file a new bug, link to the old one if you think it’s a regression.
Tracker link is in the channel topic
s
Is there any update on this?