Repository navigation
Description
Is your feature request related to a problem? Please describe.
Currently, we define a Modal as a smaller window that appears on top of the primary parent window. It usually has a shadow and a darker background. This can be problematic since "modal" can also be used to describe other elements with a shadow and similar behavior. For example, you can have a sidebar with a modal behavior, meaning it has a shadow and transitions in/out of the primary window.
Take a lot at this recent discussion and some of the confusion it can cause:
the next step to explore might be to make the sidebar behave like a modal
When you press the cog button, the sidebar opens in a modal behavior. The means it has a drop shadow, and when you click outside or press Escape, it closes and sets focus back on the block you invoked it from.
You'd still be able to see the main content in context, despite the behavior being modal.
the sidebar would open as a modal with a shadow
Is there a half-way point we could explore, where the sidebar would behave in a "modal-ish" way
One idea posed early on, was making the inspector into a modal dialog.
Describe the solution you'd like
We should rename the Modal component to "Dialog". Other systems have followed this pattern, like Material and GNOME. Dialog is more clear when talking about the component. "Modal" is commonly used to describe the behavior or visual look of other elements in a generic way:
- "a modal sidebar"
- "a dialog is a type of modal window"
Also the dialog API uses the ARIA role "dialog" so it would be consistent with that.
https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/dialog_role
By aligning on the terminology we use, we will reduce confusion and communication will be efficent.
cc @jasmussen
Activity
jasmussen commentedon Mar 4, 2019
Really dig the explanation of this, notably that it jives with the ARIA role.
It is important that we have the right terminology, it will help conversations such as the one ongoing in #13663. Though worth noting, we may not actually end up with a modal behavior for the sidebar, recent discussions go in a different direction, but your argument is still correct.
👍 👍 let's get a PR going!
davewhitley commentedon Mar 14, 2019
aria-modal=true
https://www.w3.org/TR/wai-aria-practices/examples/dialog-modal/dialog.html
Another opportunity to clarify the distinction of modal vs dialog.
afercia commentedon Mar 22, 2019
Worth noting that yes, modal is a behavior. However, dialogs can be non-modal or modal :)
aduth commentedon May 21, 2019
To repeat from the now-closed #14437:
#14437 (comment)
There is some further discussion from #14437 relevant for consideration.
gziolo commentedon Oct 20, 2019
There are is more feedback left in #16726. @ItsJonQ and @diegohaz. How do you feel about it?
diegohaz commentedon Oct 20, 2019
I'm not against keeping it
Modalas long as it behaves exactly as a modal dialog (witharia-modal, disabling body scroll, trapping focus etc.) with no option to disable it. But I think it's worth it having a non-modal dialog component too to abstract things like popovers and dropdown menus.That said, I'd go for a
Dialogcomponent that receives a prop to enable themodalbehavior:gziolo commentedon Oct 21, 2019
Right, we could keep
Modalas a shortcut for the code shared above. It sounds like something we can do without introducing any breaking changes 👍ItsJonQ commentedon Oct 21, 2019
@diegohaz I'm glad you mentioned the detail so of focus trapping, scroll handling, etc... Based on the conversation above, it sounds like there are 2 use cases (Components).
DialogandModalBut they're so so similar, from a code perspective. Like you suggested @diegohaz , it would be cool to have a single (base) component that can accommodate various use cases.
@gziolo I really like your suggestion of refactoring
Modalto act like a wrapper for<Dialog />🎉mtias commentedon Jul 13, 2021
Closing this as it's being handled in the general component work.
Add backport changelog entry for Core PR WordPress#14195
Tests: Add unit test coverage for WP_REST_Icon_Collections_Controller (…