Skip to content

Should we deprecate dialog.show()? #9376

@mfreed7

Description

@mfreed7

Now that the Popover API has landed, I'm not sure what the use case for non-modal <dialog> is. Comparing the two options:

  1. <dialog open> I'm a non-modal dialog </dialog>
  2. <dialog popover> I'm a non-modal dialog </dialog>

Both represent dialogs, and both are intended to be non-modal. Neither, therefore, inert the rest of the page. However, the popover version comes with several very nice-to-have features that I believe most developers prefer:

  1. <dialog popover> is displayed in the top-layer, so you don't have to do tricks to make sure it's on top of things and non-transformed/clipped.
  2. <dialog popover> comes with an easy declarative way to trigger, via <button popovertarget=foo>.
  3. <dialog popover> comes with light dismiss behavior, so clicking outside or hitting ESC closes it. (<dialog popover=manual> can be used if light dismiss is undesirable.)
  4. <dialog popover> comes with the beforetoggle event, which fires both when showing and hiding the dialog.

Given the advantages of the popover version, and no disadvantages that I can see, I'm not sure why developers should ever choose the non-popover version, when creating a non-modal dialog.

I think we should therefore deprecate dialog.show() and simplify things for developers. The guidance would then be:

  1. For modal dialogs, use <dialog>.showModal().
  2. For non-modal dialogs, use <dialog popover>.

(See #3567 and #9373 for efforts to bring more of the popover goodness to modal dialog.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions