diff --git a/canvas/src/components/mobile/components.tsx b/canvas/src/components/mobile/components.tsx index 9e1c8780..99af074b 100644 --- a/canvas/src/components/mobile/components.tsx +++ b/canvas/src/components/mobile/components.tsx @@ -72,8 +72,33 @@ export function TabBar({ { id: "comms", label: "Comms", icon: "pulse" }, { id: "me", label: "Me", icon: "user" }, ]; + + const handleKeyDown = (e: React.KeyboardEvent, idx: number) => { + let nextIdx: number | null = null; + if (e.key === "ArrowRight" || e.key === "ArrowDown") { + nextIdx = (idx + 1) % tabs.length; + } else if (e.key === "ArrowLeft" || e.key === "ArrowUp") { + nextIdx = (idx - 1 + tabs.length) % tabs.length; + } else if (e.key === "Home") { + nextIdx = 0; + } else if (e.key === "End") { + nextIdx = tabs.length - 1; + } + if (nextIdx !== null) { + e.preventDefault(); + onChange(tabs[nextIdx]!.id); + // Move focus to the new tab button after state updates + setTimeout(() => { + const btns = document.querySelectorAll('[role="tab"]'); + (btns[nextIdx!] as HTMLButtonElement | null)?.focus(); + }, 0); + } + }; + return (