️(react) add ariaLabel to modal

The accessibility plugin checks raise an error about modal component. Actually
we did not allow user to set an accessible name to the modal.
This commit is contained in:
jbpenrath
2025-12-08 14:54:47 +01:00
committed by Jean-Baptiste PENRATH
parent 67ba361370
commit 4e91b0adc0

View File

@@ -53,6 +53,7 @@ export type ModalProps = PropsWithChildren & {
closeOnClickOutside?: boolean; closeOnClickOutside?: boolean;
closeOnEsc?: boolean; closeOnEsc?: boolean;
preventClose?: boolean; preventClose?: boolean;
"aria-label"?: string;
}; };
export const Modal = (props: ModalProps) => { export const Modal = (props: ModalProps) => {
@@ -93,6 +94,7 @@ export const ModalInner = ({ closeOnEsc = true, ...props }: ModalProps) => {
shouldCloseOnOverlayClick={!!props.closeOnClickOutside} shouldCloseOnOverlayClick={!!props.closeOnClickOutside}
shouldCloseOnEsc={closeOnEsc} shouldCloseOnEsc={closeOnEsc}
bodyOpenClassName={classNames("c__modals--opened", NOSCROLL_CLASS)} bodyOpenClassName={classNames("c__modals--opened", NOSCROLL_CLASS)}
contentLabel={props["aria-label"] || props.title?.toString()}
> >
<div className="c__modal__scroller"> <div className="c__modal__scroller">
{!props.hideCloseButton && !props.preventClose && ( {!props.hideCloseButton && !props.preventClose && (