Keep sidebar and cmd+p items in view

This commit is contained in:
Gregory Schier
2024-08-15 05:50:38 -07:00
parent 522d293087
commit 795aaae2f5
3 changed files with 18 additions and 3 deletions

View File

@@ -0,0 +1,9 @@
import { useEffect } from 'react';
export function useScrollIntoView<T extends HTMLElement>(node: T | null, active: boolean) {
useEffect(() => {
if (active) {
node?.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
}
}, [active, node]);
}