fix: improve keyboard nav scroll - center focus, adjust margins, remove debounce

This commit is contained in:
N1C4T
2025-12-31 00:43:39 +04:00
parent 8ae806b64e
commit 2a74cf9a39
2 changed files with 9 additions and 6 deletions

View File

@@ -138,7 +138,7 @@ export function useKeyboardNavigation(
return () => window.removeEventListener('keydown', handleKeyDown);
}, [navItems, focusPos, onToggleCategory, onToggleApp]);
/* Scroll focused item into view automatically */
/* Scroll focused item into view instantly */
useEffect(() => {
if (!focusPos) return;
@@ -150,13 +150,14 @@ export function useKeyboardNavigation(
);
if (!el) return;
el.scrollIntoView({
block: 'nearest',
behavior: 'auto',
block: 'center',
inline: 'nearest',
});
}, [focusPos, navItems]);
return {
focusPos,
focusedItem,