Skip to content

Modal Component: rename to Dialog #14195

Closed

Description

@davewhitley

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:

#13663

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

  1. added
    [Type] Enhancement
    [Package] Components
    on Mar 1, 2019
  2. added
    [Type] Code Quality
    on Mar 4, 2019
  3. jasmussen commented on Mar 4, 2019

    @jasmussen
    Contributor

    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!

  4. davewhitley commented on Mar 14, 2019

    @davewhitley
    ContributorAuthor

    aria-modal=true

    Tells assistive technologies that the windows underneath the current dialog are not available for interaction (inert).

    https://www.w3.org/TR/wai-aria-practices/examples/dialog-modal/dialog.html

    Another opportunity to clarify the distinction of modal vs dialog.

  5. afercia commented on Mar 22, 2019

    @afercia
    Contributor

    Worth noting that yes, modal is a behavior. However, dialogs can be non-modal or modal :)

  6. aduth commented on May 21, 2019

    @aduth
    Member

    To repeat from the now-closed #14437:

    To note, this is a breaking change, and will need a backwards-compatibility story.

    #14437 (comment)

    There is some further discussion from #14437 relevant for consideration.

  7. gziolo commented on Oct 20, 2019

    @gziolo
    Member

    There are is more feedback left in #16726. @ItsJonQ and @diegohaz. How do you feel about it?

  8. diegohaz commented on Oct 20, 2019

    @diegohaz
    Member

    I'm not against keeping it Modal as long as it behaves exactly as a modal dialog (with aria-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 Dialog component that receives a prop to enable the modal behavior:

    <Dialog modal />
  9. gziolo commented on Oct 21, 2019

    @gziolo
    Member

    That said, I'd go for a Dialog component that receives a prop to enable the modal behavior:

    <Dialog modal />
    

    Right, we could keep Modal as a shortcut for the code shared above. It sounds like something we can do without introducing any breaking changes 👍

  10. ItsJonQ commented on Oct 21, 2019

    @ItsJonQ

    @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).

    Dialog and Modal

    But 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 Modal to act like a wrapper for <Dialog /> 🎉

  11. mtias commented on Jul 13, 2021

    @mtias
    Member

    Closing this as it's being handled in the general component work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Package] Components[Type] Code Quality[Type] Enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions