Skip to content

Commit

Permalink
fix(app): fix Touchscreen Sleep scrolling issue (#12992)
Browse files Browse the repository at this point in the history
fix(app): fix Touchscreen Sleep scrolling issue
koji authored Jun 28, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 84b46d8 commit 8259fc6
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/src/organisms/RobotSettingsDashboard/TouchScreenSleep.tsx
Original file line number Diff line number Diff line change
@@ -25,9 +25,9 @@ export function TouchScreenSleep({
setCurrentOption,
}: TouchScreenSleepProps): JSX.Element {
const { t } = useTranslation(['device_settings'])
// ToDo (kj:02/06/2023) This will be replaced config value via redux
const { sleepMs } = useSelector(getOnDeviceDisplaySettings) ?? SLEEP_NEVER_MS
const dispatch = useDispatch<Dispatch>()
const screenRef = React.useRef<HTMLDivElement | null>(null)

// Note (kj:02/10/2023) value's unit is ms
const settingsButtons = [
@@ -49,8 +49,12 @@ export function TouchScreenSleep({
)
}

React.useEffect(() => {
if (screenRef.current != null) screenRef.current.scrollIntoView()
}, [])

return (
<Flex flexDirection={DIRECTION_COLUMN}>
<Flex flexDirection={DIRECTION_COLUMN} ref={screenRef}>
<ChildNavigation
header={t('touchscreen_sleep')}
onClickBack={() => setCurrentOption(null)}
Original file line number Diff line number Diff line change
@@ -8,6 +8,8 @@ import { TouchScreenSleep } from '../TouchScreenSleep'

jest.mock('../../../redux/config')

// Note (kj:06/28/2023) this line is to avoid causing errors for scrollIntoView
window.HTMLElement.prototype.scrollIntoView = jest.fn()
const mockUpdateConfigValue = updateConfigValue as jest.MockedFunction<
typeof updateConfigValue
>

0 comments on commit 8259fc6

Please sign in to comment.