memos icon indicating copy to clipboard operation
memos copied to clipboard

Add scroll restoration when navigates back

Open kbiits opened this issue 9 months ago • 2 comments

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 avatar May 12 '24 18:05 kbiits

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 avatar May 12 '24 18:05 kbiits

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 avatar May 16 '24 14:05 kbiits