Skip to content

Commit

Permalink
fix(app): scroll to top of screen whenever route is changed (#16230)
Browse files Browse the repository at this point in the history
  • Loading branch information
smb2268 authored Sep 10, 2024
1 parent ff6a36f commit 9d9c360
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
10 changes: 9 additions & 1 deletion app/src/App/OnDeviceDisplayApp.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { Routes, Route, Navigate } from 'react-router-dom'
import { Routes, Route, Navigate, useLocation } from 'react-router-dom'
import { css } from 'styled-components'
import { ErrorBoundary } from 'react-error-boundary'

Expand Down Expand Up @@ -225,6 +225,14 @@ export function OnDeviceDisplayAppRoutes(): JSX.Element {
setCurrentNode(node)
}, [])
const isScrolling = useScrolling(currentNode)
const location = useLocation()
React.useEffect(() => {
currentNode?.scrollTo({
top: 0,
left: 0,
behavior: 'auto',
})
}, [location.pathname])

const { unfinishedUnboxingFlowRoute } = useSelector(
getOnDeviceDisplaySettings
Expand Down
3 changes: 2 additions & 1 deletion app/src/pages/ProtocolDashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,15 @@ export function ProtocolDashboard(): JSX.Element {
alignItems={ALIGN_CENTER}
backgroundColor={COLORS.white}
flexDirection={DIRECTION_ROW}
paddingTop={SPACING.spacing16}
paddingBottom={SPACING.spacing16}
position={
navMenuIsOpened || longPressModalIsOpened
? POSITION_STATIC
: POSITION_STICKY
}
top="7.75rem"
zIndex={navMenuIsOpened || longPressModalIsOpened ? 0 : 3}
zIndex={navMenuIsOpened || longPressModalIsOpened ? 0 : 2.5}
width="100%"
>
<Flex width="32.3125rem">
Expand Down
3 changes: 2 additions & 1 deletion app/src/pages/QuickTransferDashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,15 @@ export function QuickTransferDashboard(): JSX.Element {
justifyContent={JUSTIFY_SPACE_BETWEEN}
backgroundColor={COLORS.white}
flexDirection={DIRECTION_ROW}
paddingTop={SPACING.spacing16}
paddingBottom={SPACING.spacing16}
position={
navMenuIsOpened || longPressModalIsOpened
? POSITION_STATIC
: POSITION_STICKY
}
top="7.75rem"
zIndex={navMenuIsOpened || longPressModalIsOpened ? 0 : 3}
zIndex={navMenuIsOpened || longPressModalIsOpened ? 0 : 2.5}
width="100%"
>
<Flex width="32.3125rem">
Expand Down

0 comments on commit 9d9c360

Please sign in to comment.