Skip to content

armgit / Handy

Public Imported from GitHub
0

A free, open source, and extensible speech-to-text application that works completely offline.

fix: reset settings scroll position when switching sections (#2082)

wesleymatosdev7c31572d1973
diff --git a/src/App.tsx b/src/App.tsx
index a25dbc6d..24037725 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -70,6 +70,7 @@ function App() {
(state) => state.refreshOutputDevices,
);
const hasCompletedPostOnboardingInit = useRef(false);
+ const settingsScrollRef = useRef<HTMLDivElement>(null);
const isShowingOnboarding =
onboardingPreview !== null ||
onboardingStep === "accessibility" ||
@@ -84,6 +85,11 @@ function App() {
return () => document.documentElement.removeAttribute(attribute);
}, [isShowingOnboarding]);
+ // Reset the scroll position whenever the active section changes.
+ useLayoutEffect(() => {
+ settingsScrollRef.current?.scrollTo({ top: 0 });
+ }, [currentSection]);
+
useEffect(() => {
checkOnboardingStatus();
}, []);
@@ -360,7 +366,7 @@ function App() {
/>
{/* Scrollable content area */}
<div className="flex-1 flex flex-col overflow-hidden">
- <div className="flex-1 overflow-y-auto">
+ <div ref={settingsScrollRef} className="flex-1 overflow-y-auto">
<div className="flex flex-col items-center p-4 gap-4">
<AccessibilityPermissions />
<SecureInputWarning />