Skip to content

[READY] reset scroll to top on route and widget screen transitions#1120

Open
Sharqiewicz wants to merge 1 commit intostagingfrom
1067-bug-scroll-position-stays-at-the-same-height-between-the-screens
Open

[READY] reset scroll to top on route and widget screen transitions#1120
Sharqiewicz wants to merge 1 commit intostagingfrom
1067-bug-scroll-position-stays-at-the-same-height-between-the-screens

Conversation

@Sharqiewicz
Copy link
Copy Markdown
Member

@Sharqiewicz Sharqiewicz commented Apr 17, 2026

Remove scrollRestoration: true from createRouter to restore browser's native scroll-to-top on route changes.
Add useEffect in useRampNavigation to scroll to top when the active widget screen changes (Summary → Progress → Success/Failure), which TanStack Router cannot handle as these are in-route state transitions.

Closes: #1067

@Sharqiewicz Sharqiewicz requested a review from ebma April 17, 2026 13:50
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 17, 2026

Deploy Preview for vortexfi ready!

Name Link
🔨 Latest commit 3d3e2f0
🔍 Latest deploy log https://app.netlify.com/projects/vortexfi/deploys/69e23aa61d93ca000879cad4
😎 Deploy Preview https://deploy-preview-1120--vortexfi.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 17, 2026

Deploy Preview for vortex-sandbox ready!

Name Link
🔨 Latest commit 3d3e2f0
🔍 Latest deploy log https://app.netlify.com/projects/vortex-sandbox/deploys/69e23aa699176c00088e4545
😎 Deploy Preview https://deploy-preview-1120--vortex-sandbox.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@Sharqiewicz Sharqiewicz changed the title reset scroll to top on route and widget screen transitions [READY] reset scroll to top on route and widget screen transitions Apr 17, 2026
@ebma ebma requested a review from Copilot April 20, 2026 18:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to ensure scroll position resets to the top when navigating between routes and when transitioning between in-route “screens” in the ramp/widget flow (e.g., Summary → Progress → Success/Failure).

Changes:

  • Removes scrollRestoration: true from the TanStack Router createRouter configuration.
  • Adds screen-change detection in useRampNavigation and scrolls to top when the active screen changes.
  • Minor UI spacing tweak in the BRL onramp summary details (and a small TypeChain output type change).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
contracts/relayer/typechain-types/contracts/TokenRelayer.ts TypeChain output type shape changed for EIP712DomainChangedEvent.
apps/frontend/src/main.tsx Router configuration changed by removing scrollRestoration: true.
apps/frontend/src/hooks/ramp/useRampNavigation.ts Adds “active screen” computation and scroll-to-top effect on screen transitions.
apps/frontend/src/components/widget-steps/SummaryStep/BRLOnrampDetails.tsx Adjusts bottom margin on the copy button.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


useEffect(() => {
console.log("activeScreen", activeScreen);
window.scrollTo({ behavior: "instant", top: 0 });
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

window.scrollTo's behavior option only supports 'auto' or 'smooth' per the DOM spec/TypeScript libdefs. Using 'instant' is invalid and will either fail type-checking or be ignored at runtime; use 'auto' (or omit behavior) to get an immediate jump to the top (and consider setting left: 0 as well).

Suggested change
window.scrollTo({ behavior: "instant", top: 0 });
window.scrollTo({ top: 0, left: 0, behavior: "auto" });

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

);

useEffect(() => {
console.log("activeScreen", activeScreen);
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the console.log from this hook (it will run on every screen change and pollute production logs). If you need diagnostics, gate it behind a debug flag or use your existing logging/telemetry approach.

Suggested change
console.log("activeScreen", activeScreen);

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Sharqiewicz let's do this

Comment on lines +35 to +38
useEffect(() => {
console.log("activeScreen", activeScreen);
window.scrollTo({ behavior: "instant", top: 0 });
}, [activeScreen]);
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This scroll reset is implemented in useEffect, which runs after the new screen has rendered/painted; users can briefly see the old scroll position before the jump. If the requirement is to reset before showing the next screen, switch to useLayoutEffect (or perform the scroll in the same transition handler that triggers the screen change) and consider limiting it to the payment-flow transitions (e.g., only when entering progress/success/failure) to avoid unexpected jumps on other screen changes.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is really necessary to be honest. What do you think @Sharqiewicz?

});

const router = createRouter({ routeTree, scrollRestoration: true });
const router = createRouter({ routeTree });
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing TanStack Router's scrollRestoration: true likely disables router-managed scroll handling. In an SPA this usually means the scroll position will persist across route navigations (since history.pushState doesn't reset scroll), which can regress scroll-to-top between pages. If the goal is always scroll-to-top on route changes, keep router scroll restoration enabled and configure it accordingly, or add an explicit scroll reset on location changes.

Suggested change
const router = createRouter({ routeTree });
const router = createRouter({
routeTree,
scrollRestoration: true
});

Copilot uses AI. Check for mistakes.
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.

Bug: scroll position stays at the same height between the screens.

3 participants