From 064e22dc1a9fbb1e68fde471effee477d7d53332 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=B7=E9=9B=80?= <87893880+aukaukauk@users.noreply.github.com> Date: Mon, 22 Jun 2026 18:57:26 +0800 Subject: [PATCH] Fix settings scroll target positioning (#1829) --- .../settings/SettingsPageLayout.tsx | 21 +++++-------------- .../pages/MagnetometerToggleSetting.tsx | 5 ++++- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/gui/src/components/settings/SettingsPageLayout.tsx b/gui/src/components/settings/SettingsPageLayout.tsx index d69057ca4..93b91a188 100644 --- a/gui/src/components/settings/SettingsPageLayout.tsx +++ b/gui/src/components/settings/SettingsPageLayout.tsx @@ -1,7 +1,6 @@ import classNames from 'classnames'; import { ReactNode, useEffect, useRef } from 'react'; import { useLocation } from 'react-router-dom'; -import { useBreakpoint } from '@/hooks/breakpoint'; export function SettingsPageLayout({ children, @@ -12,7 +11,6 @@ export function SettingsPageLayout({ } & React.HTMLAttributes) { const pageRef = useRef(null); const { state } = useLocation(); - const { isMobile } = useBreakpoint('mobile'); useEffect(() => { const typedState: { scrollTo: string } = state; @@ -23,19 +21,10 @@ export function SettingsPageLayout({ `#${typedState.scrollTo}` ) as HTMLElement | null; if (elem) { - // stupid way of doing this, just get the closest overflow-y-auto - // usually its just the parentElem - const closestScroll = elem.closest( - '.overflow-y-auto' - ) as HTMLElement | null; - if (closestScroll) { - // The 45 is just enough padding for making the scroll look perfect - const topPadding = isMobile ? 80 : 45; - closestScroll.scroll({ - top: elem.offsetTop - topPadding, - behavior: 'smooth', - }); - } + elem.scrollIntoView({ + block: 'start', + behavior: 'smooth', + }); } }, [state]); @@ -58,7 +47,7 @@ export function SettingsPagePaneLayout({ return (
-
+
{l10n.getString( 'settings-general-tracker_mechanics-use_mag_on_all_trackers'