Skip to content

[Popup] Should light dismiss be cancellable on popup? #321

Closed
@melanierichards

Description

@melanierichards

On MS Edge Explainers #457, @mfreed7 asked:

During implementation, the question has come up about whether the Escape key light dismiss behavior (or really, any of the light dismiss behavior such as clicking outside) should be author-cancellable. I.e. user hits Escape, but author has added 'keydown' event handler on document.body, and does preventDefault(). Should the currently-top popup be hidden?

@domenic said:

First, I think the platform needs to have both author-cancelable and non-cancelable close signals. Notably, exiting fullscreen cannot be author-cancelable. But, exiting a <dialog> is (and we have some strong feedback that it should continue to be).

Second, I think that the behavior should be uniform. So, you can prevent dialog closing by preventDefault()ing Esc on document. It also has an explicit cancel event which can be preventDefault()ed. (But, its close cannot be preventDefault()ed; that happens after the fact.) This means that, IMO, anything with cancelable close behavior should behave the same way, both in terms of keydown event listeners (on desktop) and also having a cancel event where applicable.

(Note: the modal close signals explainer was written before I realized this about dialog. Per slightlyoff/history_api#13, we're probably going to update the event name for ModalCloseWatcher in the way the above paragraph discusses, i.e. change beforeclose to cancel, to match <dialog>. Maybe we'll even rename it to ModalCancelWatcher.)

I don't have a strong opinion on which category <popup> should go in. @melanierichards mentioned in #455 that the current plan is for it to be in the uncancelable category. If so, then I think it should behave like fullscreen and keydown listeners shouldn't be able to stop it, and it shouldn't have a cancel event, etc.

Now, there's an interesting wrinkle for author-cancelable close signals regarding the Android back button, which is that canceling them can be used to trap the user by disabling the back button. Our modal close signals explainer has some mitigations for this, and for platform predictability, it applies those mitigations on all platforms.

Metadata

Metadata

Assignees

No one assigned

    Labels

    popoverThe Popover API

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions