-
Notifications
You must be signed in to change notification settings - Fork 230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable ESC key to close modal #105
Comments
I would like this feature as well. I understand the concern about accessibility but I would like to use a modal that user is unable to close until they perform an action. |
Does anyone have a solution for this, a hack or similar? |
As a project we decided to take a stance on what a accessible modal should be. Disabling modal close on Understandably, this feature could a deal breaker in some scenarios, however there are plenty of modal libraries which would fulfill this need. |
I have a solution and a hack: SolutionThe team is right! Don't try to prevent escape, it's not good UX. In your modal let the user know that ignoring or closing the modal brings with it default behavior. It's quite common to see something like this with respect to GDPR. Consider Gitlab's homepage, at the bottom (today) there is a footer with cookie options and a button. "You consent to our cookies if you continue to use our website." That's default behavior in action, but of course be careful about default opt-in, in some cases you must default opt-out of certain kinds of data collection. Either way, a default should be available and esc can perform that default (just use the In my use case, the user starts a long-running web worker and if their data has certain properties the worker pauses to ask "Should I use method A or method B to continue this job?". It can't go on without a choice, what should I do if they hit HackIf you really love this little library, but you just gotta turn off that escape feature, then just remove it. It's a pretty small library, there's one simple line of code that closes the modal on escape. So you could just:
|
I had the same problem when using Micromodal.js, like, 5 minutes ago, I do this in two steps :
I think it is number 2 which you were looking for
|
This really doesn't have anything to do with accessibility. Accessibility is about ensuring that features that are expected to be "accessible" to any standard user are "accessible" to all standard users (i say standard because some features could be restricted by unrelated things like paywalls). If a modal is not meant be closable by any user, then that would include users that require the use of assistive technologies. The WCAG guideline that outlines the use of the ESC key to close modal is to make the modal close function (not the modal) accessible to users that can only use keyboard commands. This feature is specific to making the close functionality accessible to all user. In general term, again, all feature/information should be accessible to all users. If a feature doesn't exist in the first place, then there's nothing to make accessible. For the same reason there's no reason to add alternative text or title to hidden elements, since the intention is that no one consumes this information (screen readers wont even read these anyway for this reason). As far as what is the best UX, that's not even a concrete thing. UX is a highly subjective topic, and more importantly a very distant second to what a client want for their site. That said the maintainer of this project are free to do as they like. It's their project. I've built my own modals from scratch, but i like most ppl don't have time for that (ain't nobody got time for that), so if you're going to use plugins, you're going to be restricted to the present features & functionality |
100% |
Use case - User wants to use micromodal to display a "We use cokies" message and don't want visitors to close the modal until they agree or disagree
Ref. https://twitter.com/imariohernandez/status/998704962212265984
The text was updated successfully, but these errors were encountered: