mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-22 17:39:12 +01:00
Keep sidebar and cmd+p items in view
This commit is contained in:
9
src-web/hooks/useScrollIntoView.ts
Normal file
9
src-web/hooks/useScrollIntoView.ts
Normal 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]);
|
||||
}
|
||||
Reference in New Issue
Block a user