Git Product home page Git Product logo

Comments (8)

davidtheclark avatar davidtheclark commented on June 27, 2024

Can you find any evidence in a spec that this is the case? And have you tested across browsers?

from tabbable.

felipeochoa avatar felipeochoa commented on June 27, 2024

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.

davidtheclark avatar davidtheclark commented on June 27, 2024

@felipeochoa: Thanks for digging into it a little. Sounds like the right plan to me.

from tabbable.

davidtheclark avatar davidtheclark commented on June 27, 2024

@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.

felipeochoa avatar felipeochoa commented on June 27, 2024

@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.

davidtheclark avatar davidtheclark commented on June 27, 2024

@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.

felipeochoa avatar felipeochoa commented on June 27, 2024

Thanks! Submitted PR #8

from tabbable.

davidtheclark avatar davidtheclark commented on June 27, 2024

Closed by #8.

from tabbable.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.