diff --git a/frontend/src/components/ui/sidebar.tsx b/frontend/src/components/ui/sidebar.tsx index b276f8ec..ecdc3988 100644 --- a/frontend/src/components/ui/sidebar.tsx +++ b/frontend/src/components/ui/sidebar.tsx @@ -133,7 +133,11 @@ export function SidebarProvider({ }, [escapeBlocked, isMobile, open, openMobile, setOpen, setOpenMobile]); useEffect(() => { - if (openMobile && !wasMobileOpen.current) window.requestAnimationFrame(() => sidebarTriggerRef.current?.focus()); + if (openMobile && !wasMobileOpen.current) { + const focusDrawer = window.requestAnimationFrame(() => sidebarTriggerRef.current?.focus()); + wasMobileOpen.current = true; + return () => window.cancelAnimationFrame(focusDrawer); + } if (!openMobile && wasMobileOpen.current) insetTriggerRef.current?.focus(); wasMobileOpen.current = openMobile; }, [openMobile]); @@ -173,9 +177,11 @@ export function SidebarProvider({ export function Sidebar({ id, className, ...props }: ComponentProps<"aside">) { const { isMobile, open, openMobile, setOpenMobile } = useSidebar(); + const sidebar =