From 20c1dfa91ffd836fb7fd81ae7ecfaa8fbc97507d Mon Sep 17 00:00:00 2001 From: koji Date: Tue, 27 Jun 2023 14:41:14 -0400 Subject: [PATCH 1/2] fix(app): fix Touchscreen Sleep scrolling issue When tap Sleep settting, the touchscreen app display the top --- .../organisms/RobotSettingsDashboard/TouchScreenSleep.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/organisms/RobotSettingsDashboard/TouchScreenSleep.tsx b/app/src/organisms/RobotSettingsDashboard/TouchScreenSleep.tsx index 0a94ed53fa8..0dac7fccb12 100644 --- a/app/src/organisms/RobotSettingsDashboard/TouchScreenSleep.tsx +++ b/app/src/organisms/RobotSettingsDashboard/TouchScreenSleep.tsx @@ -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() + const screenRef = React.useRef(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 ( - + setCurrentOption(null)} From e5cad65386241d6a9f6b1430849c2c6ed597f887 Mon Sep 17 00:00:00 2001 From: koji Date: Wed, 28 Jun 2023 13:48:09 -0400 Subject: [PATCH 2/2] to avoid test error for scrollIntoView --- .../RobotSettingsDashboard/__tests__/TouchScreenSleep.test.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/organisms/RobotSettingsDashboard/__tests__/TouchScreenSleep.test.tsx b/app/src/organisms/RobotSettingsDashboard/__tests__/TouchScreenSleep.test.tsx index 23fe2442d87..0913ae292f0 100644 --- a/app/src/organisms/RobotSettingsDashboard/__tests__/TouchScreenSleep.test.tsx +++ b/app/src/organisms/RobotSettingsDashboard/__tests__/TouchScreenSleep.test.tsx @@ -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 >