Active
Project:
Layout Builder Modal
Version:
2.0.0
Component:
User interface
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
7 Feb 2020 at 23:37 UTC
Updated:
23 Feb 2026 at 23:59 UTC
Jump to comment: Most recent
Comments
Comment #2
Webbeh+1. I wonder if #2253257: Use a modal for entity delete operation links might be a potential solution to this issue?
Comment #3
johnwebdev commentedjQuery UI dialog does have a configuration option for this: https://api.jqueryui.com/dialog/#option-closeOnEscape
However, while testing this locally (a while ago) it didn't seem to work as expected. I did not have time to investigate further.
Comment #4
andrewmacpherson commentedPlease don't do this!
Modal dialogs are supposed to be dismissible by pressing the escape key. It's how they behave on desktop applications, and it's been that way for about 3 decades now. It's also how they are supposed to behave according to the ARIA Authoring Practices; and the jQueryUI dialogs in core implement this correctly.
What's more, you are supposed to lose all your changes when dismissing the dialog with the escape key. That's the whole point; it's a way to abort the entire dialog operation. It's particularly useful when you have accidentally invoked a dialog which you didn't intend to open.
The proposed resolutions...
This will confound the expectations of keyboard users and assistive tech users. I don't recommend it at all.
This is overkill, because the normal behaviour of the escape key is to close the modal dialog. The irony is that such an "Are you sure?" prompt would also need to be modal, and respond to the escape key too.
Comment #5
iacwebdev commentedI'm all about accessibility - I'm a big proponent of it in my work unit, and spend a lot of time writing accessibility training guides and reviewing sites for accessibility issues. So, I can appreciate the concerns of breaking expectations for screen readers and keyboard users.
I'd postulate that what this module is doing is going well beyond the traditional use of a modal dialog. It's one thing to follow the traditional keyboard patterns with a modal dialog that only has a small number of fields where there won't be too many potential changes lost if the escape key is hit by accident. But, with Layout Builder Modal, you're very likely to have a CKEditor rich text field where lots of editing work could happen followed by one accidental press of the escape key wiping it all out. That's not something I appreciate, and I certainly don't want my content editors complaining to me when that happens to them.
The alternative to my suggestions is to question whether this module should be using a modal dialog at all. As I try to think of alternatives, I think of the mechanism that CKEditor uses to display full-screen (it's "Maximize" function). That mode doesn't respond to the escape key, so if this module could switch to it, that would be ideal, not only for preventing accidental data loss, but for providing more usable workspace than a modal. Of course, it would then be odd to still call it "Layout Builder Modal", but I've seen module authors change the name of their module in the past when the underlying concept changes enough. Or, maybe they could just build a sister module that implements the CKEditor style functionality.
If that's too big of a change to make, I'm fine with retracting my original first suggestion in favor of the second: the escape key should produce an "Are You Sure?" prompt. It may be overkill for a normal modal, but this is not a normal usage of a modal - it's almost like a "super" modal given the amount of editing work that can occur inside the modal. In any case, I don't see any actual harm to accessibility to go this route, as setting "overkill" aside, keyboard expectations would be maintained properly: The first press of escape would bring up the "Are You Sure?" modal, while a second press would dismiss it and take you back to the Layout Builder Modal modal. Fully dismissing the modal would be simply a matter of pressing escape followed by enter/return to confirm. All of that should make sense to any keyboard user.
Comment #6
gcbThis seems like a very old issue... but I just want to come in here to support @iacwebdev's take above -- were doing way to much in this modal for escape to be helpful. I hit escape to cancel an auto-complete dialogue and accidentally close 4 minutes of content entry -- it's a very bad experience.