Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 5 additions & 16 deletions gui/src/components/settings/SettingsPageLayout.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -12,7 +11,6 @@ export function SettingsPageLayout({
} & React.HTMLAttributes<HTMLDivElement>) {
const pageRef = useRef<HTMLDivElement | null>(null);
const { state } = useLocation();
const { isMobile } = useBreakpoint('mobile');

useEffect(() => {
const typedState: { scrollTo: string } = state;
Expand All @@ -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]);

Expand All @@ -58,7 +47,7 @@ export function SettingsPagePaneLayout({
return (
<div
className={classNames(
'bg-background-70 rounded-lg px-4 py-8 flex xs:gap-4 w-full relative',
'bg-background-70 rounded-lg px-4 py-8 flex xs:gap-4 w-full relative scroll-mt-12 mobile:scroll-mt-20',
className
)}
{...props}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ export function MagnetometerToggleSetting({

return settingType === 'general' ? (
<>
<div className="flex flex-col pt-5 pb-3" id={id}>
<div
className="flex flex-col pt-5 pb-3 scroll-mt-12 mobile:scroll-mt-20"
id={id}
>
<Typography variant="section-title">
{l10n.getString(
'settings-general-tracker_mechanics-use_mag_on_all_trackers'
Expand Down
Loading