Repository navigation
fix(tanstack): keep the page's scroll when Studio shows a save - #809
Merged
Merged
Conversation
After every load TanStack Router restores the position saved for the URL or scrolls to the top, and invalidate() takes no resetScroll: an editor working on the footer was sent back up on every save. While a Studio refresh runs, scrollRestoration is a function answering false, which the router reads as "leave the scroll alone"; the site's own setting is back two frames after the last render. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
🎉 This PR is included in version 8.16.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
tlgimenes
added a commit
to deco-sites/demo-storefront
that referenced
this pull request
Nov 10, 2026
8.16.1 keeps the page's scroll when Studio shows a save: the site editor's preview no longer jumps to the top after each edit (decocms/blocks#809). Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
With #808 live, a save in Studio's site editor re-renders a TanStack page through its router. After every load the router either restores the position saved for the URL or scrolls to the top, and
router.invalidate()has noresetScrolloption. So an editor working on the footer was scrolled back to the top on every save. The navigation path already passedresetScroll: false, but the invalidate after it, and the refresh for the page's own URL, didn't.What
StudioRefreshruns each refresh withrouter.options.scrollRestorationset to a function that answersfalse. The router reads that as "leave the scroll alone", for both restoring and resetting. The site's own setting comes back two frames after the last render, so a later navigation scrolls as usual.router.refresh()androuter.replace(…, { scroll: false })already keep the scroll.Verification
__decoStudioRefresh(location.href)went to y=0. Running the samerouter.invalidate()withscrollRestorationoverridden like this kept it near the footer, and the page rendered the new data.StudioRefresh.test.tsx: restoration answersfalseduring the loads of both paths and is back to the site's value afterwards, including after a failed refresh.bun run checkpasses.vitest run packages/tanstack: 194 pass.🤖 Generated with Claude Code
Summary by cubic
Keeps the page's scroll position when Studio shows a save on TanStack pages. Previously, re-rendering the page through
router.invalidate()made the router restore the URL's saved position or scroll to the top, so an editor working on the footer jumped back up on every save.StudioRefreshnow setsrouter.options.scrollRestorationto a function answeringfalsewhile the refresh runs, which the router reads as "leave the scroll alone". The site's own setting is restored two frames after the last render; overlapping refreshes share the override, and a failed refresh also gives it back. Next.js was already unaffected, sincerouter.refresh()androuter.replace(…, { scroll: false })keep the scroll.Written for commit fb9a7a9. Summary will update on new commits.