diff --git a/frontend/src/components/ui/tabs.tsx b/frontend/src/components/ui/tabs.tsx index 7e3f98b0..028e4600 100644 --- a/frontend/src/components/ui/tabs.tsx +++ b/frontend/src/components/ui/tabs.tsx @@ -38,6 +38,7 @@ const TabsList = React.forwardRef< >(({ className, ...props }, ref) => (
( const { value: selectedValue, onValueChange } = useTabsContext() const isSelected = value === selectedValue + const handleKeyDown = (e: React.KeyboardEvent) => { + if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') { + e.preventDefault() + const tabList = e.currentTarget.closest('[role="tablist"]') || e.currentTarget.parentElement + const tabs = Array.from(tabList?.querySelectorAll('[role="tab"]') || []) + const currentIndex = tabs.indexOf(e.currentTarget) + const nextIndex = e.key === 'ArrowLeft' + ? (currentIndex - 1 + tabs.length) % tabs.length + : (currentIndex + 1) % tabs.length + const nextTab = tabs[nextIndex] as HTMLButtonElement + nextTab?.focus() + nextTab?.click() + } + } + return (