Comments (8)
Can you find any evidence in a spec that this is the case? And have you tested across browsers?
from tabbable.
Not sure if these are the correct and most up-to-date documents, but:
From the html5 user Interaction section
Modulo platform conventions, it is suggested that for the following elements, the tabindex focus flag be set:
- [snip]
- Editing hosts
And from the ContentEditable spec
editing host: An editing host is a node that is an HTML element with a contenteditable attribute set to something else than the
false
state.
I've also tested on the latest Chrome, Firefox and Edge, and all allow tabbing into contenteditable
from tabbable.
@felipeochoa: Thanks for digging into it a little. Sounds like the right plan to me.
from tabbable.
@felipeochoa I'm open to a PR adding this. When I started looking into it I ran into some problems making it non-trivial:
- In test environments I'm getting
contenteditableElement.tabIndex === -1
, which makes us unable to test those elements. I see this result in the current Jest suite, which uses jsdom; so I tried switching over to Karma and Firefox but saw the same thing. - How should elements behave if they are inheriting
contenteditable
from a parent?
Until you or someone else is able to take care of these problems, what I'd recommend is applying tabindex="0"
to your contenteditable
elements so they will be recognized.
from tabbable.
@davidtheclark I updated the code pen to check both things out. It seems like children who inherit contenteditable
don't get tabbed into natively and have contentEditable
set to inherit
, so that won't be a problem (just exclude them from tabbable).
I confirmed your first point in both Firefox and Chrome, though IE11 and Edge both actually report tabindex = 0
(see the updated pen). This point looks harder/impossible to resolve, since there's no apparent way to distinguish between <div contenteditable></div>
and <div contenteditable tabindex="-1"></div>
-- even though the browser allows tabbing into one but not the other. There's an existing bug in Firefox for this, and I filed one with Chromium.
I suppose for the time being tabindex="0"
it is!
from tabbable.
@felipeochoa Excellent digging. If you think it would help others in your situation to add a note to the README, I'd welcome a PR.
from tabbable.
Thanks! Submitted PR #8
from tabbable.
Closed by #8.
from tabbable.
Related Issues (20)
- element.matches not working in ie 11. HOT 5
- Scroll containers HOT 3
- isTabbableRadio doesn't properly escape query selectors HOT 4
- Use @testing-library/dom and Jest for tests HOT 3
- Add code coverage badge to the README HOT 5
- Restore actual browser testing with Cypress HOT 8
- support inert attribute HOT 13
- Exclude form elements in `:disabled` fieldset HOT 2
- Optimizing displayCheck: 'full' HOT 9
- Bug: isDisabledFromFieldset doesn't check the top-most disabled <fieldset> HOT 3
- Safari: Object passed in getCheckedRadio is not iterable, causing a for loop error HOT 2
- v5.3.0 breaks literally all of our usage of `tabbable` 😅 when called on a node not attached to the document HOT 40
- [MAJOR] isHidden should exclude detached nodes by default
- Firefox throws an error when checking disabled on non button element HOT 4
- IE support broken in v5.3.2+ HOT 1
- tabbable breaks when processing an element with a "scope" attribute HOT 6
- jest error Your focus-trap must have at least one container with at least one tabbable node in it at all times HOT 2
- Can't make it work testing with tabbable mocked HOT 7
- jsdom issue: 'slot):not([inert]' is not a valid selector HOT 7
- Remove nwsapi v2.2.2 override once bug is fixed
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 tabbable.