Skip to content

Commit

Permalink
[PR feedback] Site menu aria-label
Browse files Browse the repository at this point in the history
  • Loading branch information
cee-chen committed Aug 11, 2023
1 parent 3b1292d commit c9e6634
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ exports[`EuiCollapsibleNavBeta renders initialIsCollapsed 1`] = `
data-focus-lock-disabled="disabled"
>
<nav
aria-label="Site menu"
class="euiFlyout euiCollapsibleNav euiCollapsibleNavBeta emotion-euiFlyout-none-noMaxWidth-push-left-left-euiCollapsibleNavBeta-left-isPush-isPushCollapsed"
data-test-subj="nav"
id="generated-id_euiCollapsibleNav"
Expand Down Expand Up @@ -177,7 +178,7 @@ exports[`EuiCollapsibleNavBeta responsive behavior makes the overlay flyout full
>
<nav
aria-describedby="generated-id"
aria-label="Site navigation"
aria-label="Site menu"
class="euiFlyout euiCollapsibleNav euiCollapsibleNavBeta emotion-euiFlyout-none-noMaxWidth-overlay-left-euiCollapsibleNavBeta-left-isOverlayFullWidth"
data-autofocus="true"
id="generated-id_euiCollapsibleNav"
Expand Down
16 changes: 13 additions & 3 deletions src/components/collapsible_nav_beta/collapsible_nav_beta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ export type EuiCollapsibleNavBetaProps = CommonProps &
* take up the full width of the page.
*/
width?: number;
/**
* Overlay flyouts are considered dialogs, and dialogs must have a label.
* By default, a label of `Site menu` will be applied.
*
* If your usage of this component is not actually for site-wide navigation,
* please set your own `aria-label` or `aria-labelledby`.
*
* @default 'Site menu'
*/
'aria-label'?: string;
};

export const EuiCollapsibleNavBeta: FunctionComponent<
Expand Down Expand Up @@ -157,9 +167,9 @@ export const EuiCollapsibleNavBeta: FunctionComponent<
conditionalId: id,
suffix: 'euiCollapsibleNav',
});
const dialogAriaLabel = useEuiI18n(
const defaultAriaLabel = useEuiI18n(
'euiCollapsibleNavBeta.ariaLabel',
'Site navigation'
'Site menu'
);

const buttonRef = useRef<HTMLDivElement | null>(null);
Expand Down Expand Up @@ -188,7 +198,7 @@ export const EuiCollapsibleNavBeta: FunctionComponent<
// Wait for any fixed headers to be queried before rendering (prevents position jumping)
const flyout = fixedHeadersCount !== false && (
<EuiFlyout
aria-label={isOverlay ? dialogAriaLabel : undefined} // Overlay flyouts are dialogs and need a label. Push flyouts are not dialogs.
aria-label={defaultAriaLabel}
{...rest} // EuiCollapsibleNav is significantly less permissive than EuiFlyout
id={flyoutID}
css={cssStyles}
Expand Down

0 comments on commit c9e6634

Please sign in to comment.