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

Add scroll restoration when navigates back #3355

Closed
wants to merge 2 commits into from

Conversation

kbiits
Copy link
Contributor

@kbiits kbiits commented May 12, 2024

This PR fixes #3277 issue.

I refactor the Home component to make the react-router-dom ScrollRestoration work. There are some useless re-rendering that makes the ScrollRestoration not work.

Here's the demo
https://www.veed.io/view/d774a53a-fcd9-4c9f-afe2-d145e204dcc2?panel=share

@kbiits kbiits requested a review from boojack as a code owner May 12, 2024 18:28
@kbiits
Copy link
Contributor Author

kbiits commented May 12, 2024

Sorry, I've just noticed there's a bug. When we navigate back from memo detail and the Home page already has more than 1 page of memos in the store (I mean the zustand store), the next page token is reset.

We need to move it out to the zustand store so it doesn't reset when navigating back.

I'll take a look at this when I have spare time.

@kbiits
Copy link
Contributor Author

kbiits commented May 16, 2024

I encountered many problems because we reused the same store on multiple pages (the homepage, the explore page, and others).

I think we can do a workaround. By using full page reload when navigating pages between home, explore, timeline, and other pages that show memo lists and use the same store, we can prevent the bug and enable the scroll restoration feature.

@kbiits kbiits closed this May 25, 2024
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

Successfully merging this pull request may close these issues.

Remember memos list browsing location
1 participant