Assigned
Status Update
Comments
ol...@gmail.com <ol...@gmail.com> #2
This actually has nothing to do with NavHostFragment, but is the behavior of NavController's setGraph().
When you call navController.setGraph(R.navigation.navigation_graph), it stores that ID and will restore that ID automatically.
If you were to instead use:
NavInflater navInflater = new NavInflater(this, navController.getNavigatorProvider());
navController.setGraph(navInflater.inflate(R.navigation.navigation_graph));
Then NavController would not restore the graph itself and the call to restoreState() you point out would only restore the back stack state, etc. but would wait for you to call setGraph again.
You're right that the inconsistency between the two setGraph methods is concerning. We'll take a look.
When you call navController.setGraph(R.navigation.navigation_graph), it stores that ID and will restore that ID automatically.
If you were to instead use:
NavInflater navInflater = new NavInflater(this, navController.getNavigatorProvider());
navController.setGraph(navInflater.inflate(R.navigation.navigation_graph));
Then NavController would not restore the graph itself and the call to restoreState() you point out would only restore the back stack state, etc. but would wait for you to call setGraph again.
You're right that the inconsistency between the two setGraph methods is concerning. We'll take a look.
Description
Compose BOM version: 2024.12.01.
Jetpack Compose component used: FocusRestorer.
Android Studio Build: Android Studio Ladybug | 2024.2.1.
Kotlin version: 2.0.0
Problem
Focushandling on TV with multiple Rows in a LazyColumn where the first Row is aligned at the bottom of the screen. When navigating up an down between the rows, the focus sometimes skips 1 or more rows.
Reproduce
Comment
Spend a lot of time searching for a fix. In the end I wrote a custom FocusRestorer which doesn't pin its item when leaving the viewport.
I wrote another bug regarding the pinning, because no item will be disposed after scrolling it out of the viewport when using FocusRestorer. Which could result in bad perfomance results when you are using a huge amount of items.