Open OliverJAsh opened 2 months ago
On a related note, I also noticed that it doesn't work when v7_startTransition
is enabled. This is because useNavigation().state
is always idle
.
https://stackblitz.com/edit/github-eve2dr-glrg3x?file=src%2Fapp.tsx
@brophdawg11, do you think React Router could publish an official version of this so we don't have to try to integrate from the outside? It's proving to be a challenge.
I'll check with Ryan and Michael on their appetite for inlining! I do think that a foolproof solution to this likely requires access to router internals for this specific no-loader case, and also for more advanced preventScrollReset
behaviors - see https://github.com/remix-run/react-router/pull/10468#issuecomment-1578935980.
That community PR was only for changing the scroll container, not supporting multiple scroll containers - so maybe this package addresses the shortcoming that stalled out that PR.
Thanks @brophdawg11!
In the mean time @OliverJAsh, I'm afraid I only have the bandwidth to address issues that are impacting me and my own work at the time. I'm happy to look at a PR though.
If I understand correctly, this will update positions when the navigation state is not
idle
, e.g. when it'sloading
. This will only happen if the next route has a loader.Here's a reduced test case to illustrate the problem: https://stackblitz.com/edit/github-eve2dr-vm34va?file=src%2Fapp.tsx
What are your thoughts on updating this to save the scroll position even when navigating to a route that doesn't have a loader?