fix(ui): scroll to top when switching device sidebar tabs

Wraps setActiveTab to also scroll #main-content to top. Prevents
stale scroll position when navigating from a long tab (e.g. Firewall)
to a short one (e.g. SNMP).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jason Staack
2026-03-21 13:54:09 -05:00
parent 91eea99aca
commit 0313909d93

View File

@@ -302,7 +302,11 @@ function DeviceDetailPage() {
const queryClient = useQueryClient()
const { user } = useAuth()
const [showCreds, setShowCreds] = useState(false)
const [activeTab, setActiveTab] = useState('overview')
const [activeTab, setActiveTabRaw] = useState('overview')
const setActiveTab = (tab: string) => {
setActiveTabRaw(tab)
document.getElementById('main-content')?.scrollTo(0, 0)
}
const [editOpen, setEditOpen] = useState(false)
const { mode, toggleMode } = useSimpleConfigMode(deviceId)