Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NavigationAdvancedSample doesnt save/restore RecyclerView state #1063

Open
J-Swift opened this issue Oct 8, 2022 · 2 comments
Open

NavigationAdvancedSample doesnt save/restore RecyclerView state #1063

J-Swift opened this issue Oct 8, 2022 · 2 comments

Comments

@J-Swift
Copy link

J-Swift commented Oct 8, 2022

When navigating between the Leaderboard and other tabs, the Leaderboard is recreated every single time you return. The recycler state should be retained. This is the same issue I'm having with my local app and was hoping that I was doing something wrong but it looks like this is just how Navigation works with a bottom nav?

Repro:

  • Select Leaderboard tab
  • Scroll to bottom of the list
  • Select Register tab
  • Select Leaderboard tab
  • Notice that we are scrolled back to the top

Even if I add onSaveInstanceState it never gets called.

@J-Swift
Copy link
Author

J-Swift commented Oct 8, 2022

Actually, messing around more with this example, I realized it seems the state of the backstack doesnt work at all between tabs. Another example:

  • Select Home tab
  • Click 'About', which pushes a fragment onto the 'Home' stack
  • Select Leaderboard tab
  • Select Home tab
  • Notice that we are back on the main Home page, not the About page

I had this same issue locally when trying to setup sub navgraphs, and ended up having to abandon them as a design and use custom back button handling to keep "proper" state maintained.

Is this really working as intended? These all seem like bugs to me, and the most frustrating thing is that this is absolutely the "happy path" of app design. None of the 2 situations I describe seem abnormal, on the contrary it is how apps have been designed for at least a decade.

@bqfa
Copy link

bqfa commented Oct 21, 2023

In NavigationAdvancedSample I Followed your given step and when select home tab again its still on About page .

But My issue is in my app fragment is recreated

  • Select Home Bottom Menu Scroll down
  • Click on Profile Bottom Menu
  • Now Select Home Bottom Menu again and Fragment recreated because Recyclerview position set on First position and also it's take 1 second white screen when back on Home Fragment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@J-Swift @bqfa and others