diff --git a/src/panel/Panel.tsx b/src/panel/Panel.tsx index 7ff0700..28f9921 100644 --- a/src/panel/Panel.tsx +++ b/src/panel/Panel.tsx @@ -150,6 +150,28 @@ export function Panel() { } }, [tabId, state.reduxDetected]); + // WAI-ARIA Tabs — arrow-key roving focus between tabs + const handleTabKeyDown = useCallback((e: React.KeyboardEvent, currentIndex: number) => { + const tabCount = TABS.length; + let nextIndex: number | null = null; + if (e.key === 'ArrowRight') { + nextIndex = (currentIndex + 1) % tabCount; + } else if (e.key === 'ArrowLeft') { + nextIndex = (currentIndex - 1 + tabCount) % tabCount; + } else if (e.key === 'Home') { + nextIndex = 0; + } else if (e.key === 'End') { + nextIndex = tabCount - 1; + } + if (nextIndex !== null) { + e.preventDefault(); + const nextTab = TABS[nextIndex]; + handleTabChange(nextTab.id); + const nextBtn = document.getElementById(`tab-${nextTab.id}`); + nextBtn?.focus(); + } + }, [handleTabChange]); + useEffect(() => { fetchState(); @@ -427,25 +449,38 @@ export function Panel() { -