Giter Site home page Giter Site logo

aleventhal / treegrid-tab-active-cells Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 96 KB

Another accessible treegrid example, this time using the tab key to move between active cells in the focused row.

License: MIT License

CSS 10.15% HTML 21.40% JavaScript 68.46%

treegrid-tab-active-cells's Introduction

ARIA treegrid example

Jump to interactive version

Rationale

The ARIA treegrid has not gotten enough love. Docs the old specs provide recommendations for keyboard shortcuts that would conflict with browser/OS keys.

Challenges and Approach

The main challenge is that the left/right arrow key could be used to collapse/expand or to move by column. This example attempts to resolve this conflict while remaining intuitive and discoverable. Essentially: left/right collapse/expand. If the current row is already expanded, the right arrow will begin cell navigation mode, and after that, arrows/home/end will navigate by cell. In addition, tab/shift+tab move between interactive cells in the current row. To exit cell navigation mode, move left past the first cell. Note that left/right/home/end are not supported when there is a focused text input cell, as it needs those keys.

  • Ideally, screen readers would implement table navigation keys even in focus mode, launching from the current row or cell. NVDA does this in Firefox via Ctrl+Alt+Arrow, recognizing the current row as a starting position.

Markup considerations

  • roles used are treegrid, row and gridcell
  • aria-level: used to set the current level of an item, 1, 2, 3, etc.
  • aria-posinset, aria-setsize: used on a row to indicate the position of an item within it's local group, such as item 3 of 5. Unfortunately, this is not currently legal in the spec.
  • aria-rowindex, aria-rowcount, aria-colindex, aria-colcount. Not currently used, as UA/AT can compute this for fully loaded table DOMs.
  • aria-expanded (triststate): this attribute must be removed (not present) if the item cannot be expanded. For expandable items, the value is "true" or "false"
  • aria-hidden: set to "true" for child items that are currently hidden because the parent is collapsed
  • aria-owns: not currently used, awaiting discussion. Could be used for parents to identify their children, but it doesn't look like any screen readers actually use this so it seems to be a wasteful recommendation.
  • aria-labelledby or aria-describedby for headers? Not currently used, awaiting discussion
  • aria-activedescendant -- this example does not use, because it is not exposed to ATs in IE, and thus uses tabindex instead
  • aria-readonly: be default, a grid/treegrid is editable, but these tend not to be. This is mentioned in the text of the ARIA spec for grid/treegrid but doesn't seem to have made its way into the AAM. This idea originated for grids, which are like spreadsheets, where most cells are probably editable. It may not make sense for a treegrid, but this is the legacy. Bottom line: if you don't want "editable" read for every cell in some browser-screen reader combinations, you'll need to put aria-readonly="true" on the appropriate role="gridcell" elements or on the grid/treegrid itself.
  • aria-selected: used on row in the case of a multiselectable treegrid where each row begins with a checkbox. Must be set to false or true so that it is clear that row is selectable.
  • tabindex is set in the JS, as per the usual roving tabindex methodology. Specifically, we use tabindex="0" for the current item so that it is the subitem that gets focused if user tabs out and back in, and tabindex="-1" for all items where we want click-to-focus behavior enabled.

Observations with screen readers

Chrome (Canary currently required) Firefox IE11 Safari
Chomevox
  • Row nav: Previously did not read name, should be fixed in Canary, needs test
  • Cell nav: Does not read name on cells even if aria-label or aria-labelledby are set
  • JAWS
  • Row navigation: requires Chrome Canary otherwise won't read name
  • Levels not reported, item n of m not reported
  • Collapse/expand, nothing reported
  • Row navigation: levels not reported,
  • Column navigation: no issues found
  • Other: when collapsing/expanding: new collapsed/expanded state not spoken, says "row unselected", but nothing useful
  • Need to use Insert+Z to turn virtual cursor off. Does not report level or item n of m.
    NVDA
  • Row navigation: requires Chrome Canary otherwise won't ready name
  • Column navigation: Does not read column headers
  • Row navigation: levels read correctly, all seems good
  • Column navigation: cells are announced as "selected" but this seems redundant since it's not an aria-multiselectable treegrid
  • Has very cool feature where Ctrl+alt arrow can navigate cells of table from current position, without additional help from the ARIA widget. If all screen readers did this then the widget author would not need to implement the cell navigation
  • Column navigation: unlike in Firefox, NVDA does not read column labels but instead reads the column number
  • Row navigation: row numbers are reported, unlike with NVDA and Firefox. Unfortunately both row 2 and 3 are reported as row 2 :/
  • The ctrl+alt+arrow feature that is available in Firefox does not work in IE
  • VoiceOver
  • First focus: calls it a listbox
  • Column navigation: reads each item twice
  • Row navigation: does not read expanded state, completely skips reading second column for second row
  • Row navigation: doesn't let us do this, reads cells no matter what

    treegrid-tab-active-cells's People

    Contributors

    aleventhal avatar

    Stargazers

    Martin Wendt avatar

    Watchers

    Martin Wendt avatar  avatar

    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.