-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make sure the Modal dialog is always properly labelled #47885
Comments
I have added the aria label in this PR - my suggestion would be that we get this simple fix into 6.2 and then repurpose this issue to look at ways to improve the Dialog component in general post 6.2, eg. keeping the heading but visually hidden if |
@glendaviesnz thanks for looking into this and for #47898. |
I've removed the issue from WP 6.2 project board. Let's try and land general improvements before the next major versions. |
Updated Description
As suggested, I updated the title of this issue to address the problem in a more holistic way. The previous title mentioned a specific case where a Modal dialog was unlabelled:
Site editor: the global Save modal dialog is unlabelled
.The underlying problem is more general though.
A modal dialog should always be labelled. Keeping into consideration that a visible title is always strongly preferred, there are two options to label a modal dialog. The element with
role="dialog"
should:This mechanism is implemented in the Modal and it's based on the
title
and thecontentLabel
props. However, these props are not required. One of these two props should always be set to ensure proper labelling.Also, when
__experimentalHideHeader
is true to hide the modal dialog header, the H1 within the header should still be rendered. It can be visually hidden. It needs to be in the DOM though otherwise setting atitle
prop won't have any effect.Old Description
In #47142, a global 'save' panel has been wrapped in a modal dialog.
The modal dialog is unlabelled:
Any modal dialog must always be labelled by the means of:
aria-labelledby
set on the element withrole="dialog"
aria-label
attribute set on the element withrole="dialog"
In the past, there have been a few cases of unlabelled modal dialogs which had to be fixed. It would be great to enforce via code that a proper labelling mechanism is in place.
title
prop or thecontentLabel
prop? One of these two props should always be set. Cc @youknowriad 🙏__experimentalHideHeader
is true to hide the modal dialog header, the H1 within the header should still be rendered. It cab be visually hidden. It needs to be in the DOM though otherwise setting atitle
prop won't have any effect.Step-by-step reproduction instructions
Screenshots, screen recording, code snippet
No response
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: