Skip to content

Commit 649292a

Browse files
committed
fix(org): keep the current settings row in view on a short window
1 parent 6d091cc commit 649292a

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎apps/sim/platform/embedded/app/(shell)/_components/settings-navigation/settings-navigation.tsx‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client'
22

3-
import { useState } from 'react'
3+
import { useEffect, useRef, useState } from 'react'
44
import { useRouter } from 'next/navigation'
55
import { SettingsIntentLink } from '@/components/settings/settings-intent-link'
66
import { usePendingSettingsSelection } from '@/components/settings/use-pending-settings-selection'
@@ -104,12 +104,18 @@ export function SettingsNavigation({ collapsed }: SettingsNavigationProps) {
104104
navigation.activeSection
105105
)
106106
const [query, setQuery] = useState('')
107+
const nav = useRef<HTMLElement>(null)
108+
// A section low in the list opens scrolled off a short window, and the current row should show.
109+
useEffect(() => {
110+
nav.current?.querySelector('[aria-current="page"]')?.scrollIntoView({ block: 'nearest' })
111+
}, [selected])
107112
const searching = !collapsed && query.trim().length > 0
108113
const found = searching ? searchSettings(query, groups, navigation) : []
109114
const count = found.reduce((total, group) => total + group.results.length, 0)
110115

111116
return (
112117
<nav
118+
ref={nav}
113119
aria-label='Settings'
114120
className={styles.navigation}
115121
data-collapsed={collapsed || undefined}

0 commit comments

Comments
 (0)