Skip to content

Commit

Permalink
fix(app): restore scroll to top when changing desktop routes (#15995)
Browse files Browse the repository at this point in the history
Seemingly after React Router migration from v5->v6, the window retains
its scroll position even after changing routes. We would expect scroll
position to renew to the top of the window when changing routes, as the
`Route` component is updated. To force this, I pass a key to the
`React.Fragment` supplied as the `element` prop within each mapped
`Route`, following the API.

This seems to be related to a [separate top-level routing
issue](#15875) on the ODD and
should be investigated further after release. Interestingly, React
Router provides an explicit
[`ScrollRestoration`](https://reactrouter.com/en/main/components/scroll-restoration`)
component that is meant to be used to achieve the behavior that we are
seeing now, maintaining scroll position between routes, so I would think
that excluding this component would result in scroll returning to the
top by default.

Closes RQA-2953
  • Loading branch information
ncdiehl11 authored Aug 14, 2024
1 parent f73aa80 commit fffc19e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/src/App/DesktopApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export const DesktopApp = (): JSX.Element => {
<Route
key={path}
element={
<>
<React.Fragment key={Component.name}>
<Breadcrumbs />
<Box
position={POSITION_RELATIVE}
Expand All @@ -138,7 +138,7 @@ export const DesktopApp = (): JSX.Element => {
<Component />
</Box>
</Box>
</>
</React.Fragment>
}
path={path}
/>
Expand Down

0 comments on commit fffc19e

Please sign in to comment.