diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index d1ec64ccf..15f879d88 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -142,15 +142,21 @@ export function Sidebar({ useEffect(() => { if (sidebarOpen && activeItemRef.current) { - activeItemRef.current.scrollIntoView({ behavior: 'smooth', block: 'center' }); + activeItemRef.current.scrollIntoView({ + behavior: 'smooth', + block: 'center', + }); // focus on the active item if (activeItemRef.current instanceof HTMLAnchorElement) { activeItemRef.current.focus(); } else if (activeItemRef.current instanceof HTMLDivElement) { // check for the first focusable element and focus on it - const firstFocusableElement = activeItemRef.current.querySelector('button, a'); + const firstFocusableElement = + activeItemRef.current.querySelector('button, a'); if (firstFocusableElement) { - (firstFocusableElement as HTMLButtonElement | HTMLAnchorElement).focus(); + ( + firstFocusableElement as HTMLButtonElement | HTMLAnchorElement + ).focus(); } } } @@ -167,7 +173,11 @@ export function Sidebar({ key={content.id} value={`item-${content.id}`} className={`rounded-md border-none ${isActiveContent ? 'bg-primary/5' : ''}`} - ref={isActiveContent ? (activeItemRef as React.RefObject) : null} + ref={ + isActiveContent + ? (activeItemRef as React.RefObject) + : null + } > {content.title} @@ -184,7 +194,11 @@ export function Sidebar({ key={content.id} href={navigateToContent(content.id) || '#'} className={`flex w-full cursor-pointer items-center rounded-md p-4 tracking-tight hover:bg-primary/10 ${isActiveContent ? 'bg-primary/10' : ''}`} - ref={isActiveContent ? (activeItemRef as React.RefObject) : null} + ref={ + isActiveContent + ? (activeItemRef as React.RefObject) + : null + } >
@@ -215,7 +229,7 @@ export function Sidebar({ ); return ( -
+
- `item-${num}`)} className="w-full px-4 capitalize"> + `item-${num}`)} + className="w-full px-4 capitalize" + > {memoizedContent}