seems there is a bug with `.focusRestorer()` modif...
# compose-android
a
seems there is a bug with
.focusRestorer()
modifier. It's in experimental state unfortunately. Maybe someone knows a workaround?
Copy code
val focusRequester = remember { FocusRequester() }
val focusModifier = Modifier.focusRequester(focusRequester)

LazyColumn(
    modifier = Modifier.focusRestorer { focusRequester },
) { 
    // number of items is more the screen is hold, so some of them are not visible

    items(state.dynamicNavMenuItems) { dynamicNavMenuItem ->
        DynamicNavElementItem(
            modifier = if (dynamicNavMenuItem.initiallyFocused) focusModifier else Modifier,
        )
     }

    // focusModifier is assigned to last focused item that is stored as a part of state
}
the issue appears when desired item to focus is out of the screen. usecase: 1. user selected item 2. another screen is shown 3. user is returned to the screen -> focusRestorer tries to restore 4. desired view is out of visibility 5. as restorer is not so clever to scroll it fails to restore -> provided
focusRequester
is used 6. app crashes with FocusRequesterNotInitialized I tried to combine it somehow with
BringIntoViewRequester()
but no luck so far as
focusRestorer
doesn't wait for any other code. It tries to restore straight away when the screen is visible and doesn't wait for anybody. ideas?
using bom 2024.01.00
z
Please file a bug
👍 1