@@ -99,17 +99,7 @@ type LinkProps = Pick<
9999export type ParentLinkProps = React . PropsWithChildren < PageHeaderProps & LinkProps >
100100
101101const ParentLink = React . forwardRef < HTMLAnchorElement , ParentLinkProps > (
102- (
103- {
104- children,
105- sx = { } ,
106- href,
107- 'aria-label' : ariaLabel = `Back to ${ children } ` ,
108- as = 'a' ,
109- hidden = hiddenOnRegularAndWide ,
110- } ,
111- ref ,
112- ) => {
102+ ( { children, sx = { } , href, 'aria-label' : ariaLabel , as = 'a' , hidden = hiddenOnRegularAndWide } , ref ) => {
113103 return (
114104 < >
115105 < Link
@@ -435,10 +425,33 @@ const Description: React.FC<React.PropsWithChildren<PageHeaderProps>> = ({childr
435425 )
436426}
437427
428+ export type NavigationProps = {
429+ as ?: 'nav' | 'div'
430+ 'aria-label' ?: React . AriaAttributes [ 'aria-label' ]
431+ 'aria-labelledby' ?: React . AriaAttributes [ 'aria-labelledby' ]
432+ } & PageHeaderProps
433+
438434// PageHeader.Navigation: The local navigation area of the header. Visible on all viewports
439- const Navigation : React . FC < React . PropsWithChildren < PageHeaderProps > > = ( { children, sx = { } , hidden = false } ) => {
435+ const Navigation : React . FC < React . PropsWithChildren < NavigationProps > > = ( {
436+ children,
437+ sx = { } ,
438+ hidden = false ,
439+ as,
440+ 'aria-label' : ariaLabel ,
441+ 'aria-labelledby' : ariaLabelledBy ,
442+ } ) => {
443+ if ( as === 'nav' && ! ariaLabel && ! ariaLabelledBy ) {
444+ // eslint-disable-next-line no-console
445+ console . warn (
446+ 'Use `aria-label` or `aria-labelledby` prop to provide an accessible label to the `nav` landmark for assistive technology' ,
447+ )
448+ }
440449 return (
441450 < Box
451+ as = { as }
452+ // Render `aria-label` and `aria-labelledby` only on `nav` elements
453+ aria-label = { as === 'nav' ? ariaLabel : undefined }
454+ aria-labelledby = { as === 'nav' ? ariaLabelledBy : undefined }
442455 sx = { merge < BetterSystemStyleObject > (
443456 {
444457 display : 'flex' ,
0 commit comments