Comments (7)
Hi @arturi - Thanks for reporting this. Here are my thoughts on this:-
aria-hidden="true"
prevents screen readers from reading the element.tabindex="-1"
prevents the node from being focusablehidden="true"
is an html5 attribute which should visually hide your element.
Which browser and version are you using? Normally any element with hidden
or type=hidden
should be hidden by the browser. Micromodal cannot focus on hidden elements.
Now that you mention it, I am not sure if there is any need of :not([type="hidden"]):not([hidden])
in the focusable list since hiding the elements should be onus of the browser.
Additionally, a simple [hidden] { display: none;}
should do the trick if the browser does not support this natively.
@arturi @kalpeshsingh thoughts?
from micromodal.
Okay, I did some tests and it turns out the bug occurs when this input
I mention is the last “focusable element that should not be focusable“ in the modal.
Demo: https://codepen.io/anon/pen/jYyvMe, try tabbing a few times, notice how focus breaks out of the modal.
If you look in the console, the NodeList that gets logged there includes all the inputs that have hidden
and tabindex="-1"
in them, and that screws up the math, I think.
from micromodal.
Yup, seems like aria-hidden="true"
needs to explicitly excluded from being selected.
'input:not(hidden):not(disabled):not([aria-hidden])'
Problem is this would need to be set for all selectable elements. Seems like globally omiting aria-hidden="true"
does not work.
from micromodal.
Shall I send a PR with :not([aria-hidden]
in every selectable element? Or shall we think on some other solutions? Could also loop through nodes
after querySelectorAll
to remove those with hidden attributes, but that might be slower / more verbose code.
from micromodal.
In my opinion, adding :not([aria-hidden]
in every selectable element should be last option. I will check on this if we can get something clean to fix this problem.
from micromodal.
This should be fixed in 0.3.0
@arturi - Would have asked you for a PR, but it was a very small change. So I changed it myself.
@kalpeshsingh There were actually just 4 elements which I needed to add it too. If you find a better way feel free to raise a PR
from micromodal.
Thank you!
from micromodal.
Related Issues (20)
- Initialize multiple modals with different settings HOT 1
- Modals closing unexpectedly with any interaction HOT 3
- modal input label is triggering other input fields on the main page HOT 2
- Breaking change in 0.4.9: clicking the container closes the modal HOT 8
- Modal reopens after closing
- hi
- target argument is getting the parent on Safari. OnShow method. HOT 3
- Tab trapping does not work in Safari HOT 1
- onClose event is not triggered when clicking on the modal overlay HOT 7
- Window object doesn't work during gatsby build. HOT 1
- Feature idea: "non-dismissable" option HOT 1
- Esc and focus trap does not work if iframe is inside the modal HOT 3
- Modal closes when selecting a field. HOT 5
- Micromodal js not working on IOS devices HOT 5
- Add option to control whether disable Escape to close modal HOT 3
- Slick Slider HOT 1
- Nested modals don't close properly via JS api HOT 1
- Is this still being maintained? HOT 3
- Click Function For Element inside Modal Generates Error HOT 1
- "awaitCloseAnimation: true" does not sum the duration of all animations.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from micromodal.