(props: AriaMenuSectionProps)
| 39 | * @param props - Props for the section. |
| 40 | */ |
| 41 | export function useMenuSection(props: AriaMenuSectionProps): MenuSectionAria { |
| 42 | let {heading, 'aria-label': ariaLabel} = props; |
| 43 | let headingId = useId(); |
| 44 | |
| 45 | return { |
| 46 | itemProps: { |
| 47 | role: 'presentation' |
| 48 | }, |
| 49 | headingProps: heading |
| 50 | ? { |
| 51 | // Techincally, menus cannot contain headings according to ARIA. |
| 52 | // We hide the heading from assistive technology, using role="presentation", |
| 53 | // and only use it as a label for the nested group. |
| 54 | id: headingId, |
| 55 | role: 'presentation' |
| 56 | } |
| 57 | : {}, |
| 58 | groupProps: { |
| 59 | role: 'group', |
| 60 | 'aria-label': ariaLabel, |
| 61 | 'aria-labelledby': heading ? headingId : undefined |
| 62 | } |
| 63 | }; |
| 64 | } |
no test coverage detected