Skip to content

Commit

Permalink
improve NotificationModal accessibility
Browse files Browse the repository at this point in the history
  • Loading branch information
sirineJ committed Dec 4, 2024
1 parent 779b407 commit 16d765e
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

'use client';

import { type FC, type ReactNode, type SVGProps, useId } from 'react';
import { type FC, type ReactNode, type SVGProps, useId, useRef } from 'react';

import type { ClickEvent } from '../../types/events.js';
import { Image, type ImageProps } from '../Image/index.js';
Expand Down Expand Up @@ -85,12 +85,14 @@ export const NotificationModal = ({
...props
}: NotificationModalProps) => {
const headlineId = useId();
const initialFocusRef = useRef<HTMLButtonElement>(null);
const dialogProps = {
className: clsx(classes.centered, className, classes.base),
closeButtonLabel,
'aria-labelledby': headlineId,
preventClose,
onClose,
initialFocusRef,
...props,
};

Expand Down Expand Up @@ -124,6 +126,8 @@ export const NotificationModal = ({
},
secondary: actions.secondary && {
...actions.secondary,
// @ts-expect-error ref is a valid prop on a button
ref: initialFocusRef,
onClick: wrapOnClick(actions.secondary.onClick),
},
}}
Expand Down

0 comments on commit 16d765e

Please sign in to comment.