@@ -58,7 +58,7 @@ import {
5858 type SettingsSearchItem ,
5959} from "./settingsSearch" ;
6060import { useAvailableSettingsSearchItems } from "./useAvailableSettingsSearchItems" ;
61- import { useSettingsSectionNavigation } from "./useSettingsSectionNavigation " ;
61+ import { handleSettingsSectionKeyDown } from "./settingsSectionNavigation " ;
6262import { workspaceAreaProps } from "../../lib/workspaceFocus" ;
6363
6464const SnapShotIcon = createLucideIcon ( "snap-shot" , [
@@ -133,12 +133,6 @@ export function SettingsSidebarNav({ pathname }: { pathname: string }) {
133133 const navigate = useNavigate ( ) ;
134134 const currentHash = useLocation ( { select : ( location ) => location . hash } ) ;
135135 const activePath = SETTINGS_DETAIL_PAGE_PARENTS [ pathname ] ?? pathname ;
136- const navPaths = SETTINGS_NAV_GROUPS . flatMap ( ( group ) => group . paths ) ;
137- const sectionNavigation = useSettingsSectionNavigation (
138- navPaths . find ( ( to ) => activePath === to || activePath . startsWith ( `${ to } /` ) ) ??
139- navPaths [ 0 ] ??
140- "" ,
141- ) ;
142136 const searchInputRef = useRef < HTMLInputElement > ( null ) ;
143137 const [ query , setQuery ] = useState ( "" ) ;
144138 // Below md the nav is an icon rail; searching expands it over the page.
@@ -380,57 +374,55 @@ export function SettingsSidebarNav({ pathname }: { pathname: string }) {
380374 </ SidebarMenuItem >
381375 </ SidebarMenu >
382376 ) }
383- < div
384- { ...sectionNavigation . containerProps }
385- role = "tree"
386- aria-label = "Settings sections"
387- className = "flex flex-col gap-4"
388- >
377+ < div onKeyDown = { handleSettingsSectionKeyDown } className = "flex flex-col gap-4" >
389378 { SETTINGS_NAV_GROUPS . map ( ( group , index ) => (
390379 < div
391380 key = { group . heading ?? index }
392- role = "group"
393- aria-label = { group . heading ?? undefined }
394381 className = "flex flex-col gap-1 max-md:border-t max-md:border-sidebar-border max-md:pt-4 max-md:first:border-t-0 max-md:first:pt-0"
395382 >
396383 { group . heading ? (
397- // The group carries this label; a heading is not a valid tree child.
398384 < h3
399- aria-hidden = "true"
385+ id = { `settings-nav-group- ${ index } ` }
400386 className = { cn (
401387 "px-2 text-xs font-medium text-sidebar-muted-foreground/80" ,
402- ! compactSearchOpen && "max-md:hidden " ,
388+ ! compactSearchOpen && "max-md:sr-only " ,
403389 ) }
404390 >
405391 { group . heading }
406392 </ h3 >
407393 ) : null }
408- < SidebarMenu role = "presentation" >
409- { group . paths . map ( ( to ) => {
410- const Icon = SETTINGS_SECTION_ICONS [ to ] ;
411- const isActive = activePath === to || activePath . startsWith ( `${ to } /` ) ;
412- return (
413- < SidebarMenuItem key = { to } role = "presentation" >
414- < SidebarMenuButton
415- data-settings-section = { to }
416- role = "treeitem"
417- tabIndex = { sectionNavigation . tabIndexFor ( to ) }
418- aria-selected = { isActive }
419- aria-current = { isActive ? "page" : undefined }
420- isActive = { isActive }
421- onClick = { ( ) => handleSectionClick ( to ) }
422- >
423- < Icon />
424- < span
425- className = { cn ( "truncate" , ! compactSearchOpen && "max-md:sr-only" ) }
394+ { /* The heading stays outside the group it names so NVDA does not read the name twice. */ }
395+ < div
396+ role = "group"
397+ aria-labelledby = { group . heading ? `settings-nav-group-${ index } ` : undefined }
398+ >
399+ < SidebarMenu >
400+ { group . paths . map ( ( to ) => {
401+ const Icon = SETTINGS_SECTION_ICONS [ to ] ;
402+ const isActive = activePath === to || activePath . startsWith ( `${ to } /` ) ;
403+ return (
404+ < SidebarMenuItem key = { to } >
405+ < SidebarMenuButton
406+ data-settings-section = { to }
407+ aria-current = { isActive ? "page" : undefined }
408+ isActive = { isActive }
409+ onClick = { ( ) => handleSectionClick ( to ) }
426410 >
427- { SETTINGS_SECTION_LABELS [ to ] }
428- </ span >
429- </ SidebarMenuButton >
430- </ SidebarMenuItem >
431- ) ;
432- } ) }
433- </ SidebarMenu >
411+ < Icon />
412+ < span
413+ className = { cn (
414+ "truncate" ,
415+ ! compactSearchOpen && "max-md:sr-only" ,
416+ ) }
417+ >
418+ { SETTINGS_SECTION_LABELS [ to ] }
419+ </ span >
420+ </ SidebarMenuButton >
421+ </ SidebarMenuItem >
422+ ) ;
423+ } ) }
424+ </ SidebarMenu >
425+ </ div >
434426 </ div >
435427 ) ) }
436428 </ div >
0 commit comments