-
Notifications
You must be signed in to change notification settings - Fork 14
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
Option to opt-out from Focus Trap #435
Comments
Added a comment to this old issue that is along the same lines #295 (comment) It is possible to prevent clicks on ember-basic-dropdown components closing the modals by overriding the
However, because there's no equivalent option passthrough for |
As a proof-of-concept I modified the
Then in my app's
With that everything works well with dropdowns inside of a modal. I guess the question is whether |
refs mainmatter#435 refs mainmatter#295 https://github.com/focus-trap/focus-trap is used internally for keeping focus inside a modal and for clicks outside to close the modal. It's `clickOutsideDecactivates` config is exposed allowing for clicks on wormholed elements such as dropdowns inside a modal to not close the modal unexpectedly, however without the companion `allowOutsideClick` config those clicks are prevented from performing any interaction. - added `allowOutsideClick` to the options passed through from the `modals` service to the `focus-trap` initialisation
refs mainmatter#435 refs mainmatter#295 https://github.com/focus-trap/focus-trap is used internally for keeping focus inside a modal and for clicks outside to close the modal. It's `clickOutsideDecactivates` config is exposed allowing for clicks on wormholed elements such as dropdowns inside a modal to not close the modal unexpectedly, however without the companion `allowOutsideClick` config those clicks are prevented from performing any interaction. - added `allowOutsideClick` to the options passed through from the `modals` service to the `focus-trap` initialisation
refs mainmatter#435 refs mainmatter#295 https://github.com/focus-trap/focus-trap is used internally for keeping focus inside a modal and for handling modal closing on certain events. If the consuming app wants to manage deactivation/close-inducing events itself then it needs some way to pass `focus-trap` config through to turn off that functionality. - added `escapeDeactivates` to the options passed through from the `modals` service to the `focus-trap` initialisation
@zeppelin @kevinansfield I wouldn't mind having that option at all, a PR for this (including some form of documentation in the README) would be much appreciated. |
@pichfl @kevinansfield We currently patch EPM in our project: diff --git a/node_modules/ember-promise-modals/addon/components/modal.js b/node_modules/ember-promise-modals/addon/components/modal.js
index f145b4f..331ed18 100644
--- a/node_modules/ember-promise-modals/addon/components/modal.js
+++ b/node_modules/ember-promise-modals/addon/components/modal.js
@@ -30,7 +30,7 @@ export default Component.extend({
didInsertElement() {
this._super(...arguments);
- let { clickOutsideDeactivates } = this.modals;
+ let { clickOutsideDeactivates, _disableFocusTrap } = this.modals;
let element = document.getElementById(this.modalElementId);
let options = {
clickOutsideDeactivates,
@@ -44,8 +44,10 @@ export default Component.extend({
},
};
- this.focusTrap = createFocusTrap(element, options);
- this.focusTrap.activate();
+ if (!_disableFocusTrap) {
+ this.focusTrap = createFocusTrap(element, options);
+ this.focusTrap.activate();
+ } So right now this pretty much looks like a private/undocumented option. Are you cool with it, or just make it public (and optionally reverse the wording to I can update the README for any of the solutions above. |
I would prefer it being public and documented API, I feel like more people might run into this issue. I would also keep |
Some addons like Ember Power Select render outside the component they're invoked in, making it impossible to use with EPM. (Although EPS can be forced to render in place, but could be difficult to deal with for various reasons). I saw no option in Focus Trap to exclude certain selectors.
I know it would reduce accesibility, but spending time with code that handle modals if we don't have EPM also takes away precious time we could otherwise spend with making our app more accessible.
It doesn't even have to be public API, just an option that's one would only use if really needed it.
Should I open a PR?
The text was updated successfully, but these errors were encountered: