Thread
#compose
    a

    allan.conda

    1 year ago
    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
    Rahul Sainani

    Rahul Sainani

    1 year ago
    Hey I think you need to request focus from the next text field in onNext of the first text field
    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

    allan.conda

    1 year ago
    Yeah, I do that. But I shouldn’t have to I think. See this documentation in KeyboardActions
    thanks for the example btw!
    Rahul Sainani

    Rahul Sainani

    1 year ago
    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

    allan.conda

    1 year ago
    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…
    JulianK

    JulianK

    1 year ago
    As far as i understand, automatically focusing the next textfield is not expected behaviour for now, see https://issuetracker.google.com/issues/165676636
    a

    allan.conda

    1 year ago
    status is won’t fix, not reproducible. 🤔
    but good find, it might be a regression
    Zach Klippenstein (he/him) [MOD]

    Zach Klippenstein (he/him) [MOD]

    1 year ago
    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
    Samir Basnet

    Samir Basnet

    1 year ago
    Is there any update on this?