-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
useElementScrollRestoration
#9573
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
useElementScrollRestoration
#9573
Conversation
|
dbd781f
to
e097850
Compare
packages/react-router-dom/index.tsx
Outdated
// window has scrollY but normal elements have scrollTop | ||
const getScrollY = () => { | ||
const el = getScrollElement(); | ||
return el ? el.scrollY || el.scrollTop : undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't typecheck. I'm sure Ryan wanted to do this differently anyway, this was just how I did it in my patch.
@david-crespo Thank you for putting this together! I've been trying to do some housekeeping on the repo to start off 2023 and now that we've finished the "6.4 into Remix" work and things have settled down a bit. I'm going to close this PR until the linked discussion comes around and we can re-open when needed. |
See remix-run#9495 and remix-run#9573; based on work there.
See remix-run#9495 and remix-run#9573; based on work there.
See remix-run#9495 and remix-run#9573; based on work there.
First pass based on #9495. @ryanflorence will have feedback and I'm sure it'll change.
useScrollRestoration
(and<ScrollRestoration />
, which relies on it) only allows scroll restoration at thewindow
level. This does not work if the scrolling container is something other than the full page, e.g., a 2x2 grid layout where the bottom right cell is the scrolling content pane. This change preserves the current API and behavior ofuseScrollRestoration
while adding a new hookuseElementScrollRestoration
, which allows the caller to specify the ID of the scrolling container to use instead ofwindow
.