Skip to content

Conversation

@paulcam206
Copy link
Member

@paulcam206 paulcam206 commented Nov 18, 2023

Description

This was a bit of a ride. Prior to this change, the Designer's treeview control is represented in the DOM by a structure something like this:

<ul role="tree">
  <li role="treeitem">
    <div role="treeitem">some stuff</div>
  </li>
  <li role="treeitem">
    <div role="treeitem">
      <div class="expandcollapsebutton">...</div>
      <div>some more stuff</div>
    </div>
    <ul role="group">
      <li role="treeitem"><div role="treeitem">oh look! a child item!</li>
    </ul>
  </li>
</ul>

Unfortunately, it's not valid to have role="treeitem" on an element unless its parent's role is either group or tree. It turns out that, while eliding the role on the li > div causes a11y tooling to stop complaining, it also totally breaks keyboard navigation -- the user can't actually select an element in the tree because they can't put keyboard focus on the right element.

So I did what anyone would do and basically rewrote keyboard navigation for the treeview control.

The old model was tab-based. Each node in the tree and each expand/collapse chevron had tabIndex="0". With focus on a node in the tree, <Tab> effectively means "if this node has children, focus the expand/collapse chevron", otherwise focus the next nearest sibling. <SPC> or <RET> means "expand/collapse children" or "select this node" depending on what's currently in focus. Aside from not matching a11y best practices for Treeviews, this approach has a number of downsides from a usability perspective:

  • if the user has keyboard focus on the last of 20 Columns, the user must press <S-TAB> 20 times to put focus on the parent ColumnSet
  • if the user has selected an element in the middle of the tree, they have to <TAB> or <S-TAB> a bunch of times to get out of the tree
  • the expand/collapse chevron is always in the tabbing order even if the user never utilizes this functionality

The new model follows the aforementioned best practices:

  • You can navigate using arrow keys in the way you'd expect (<LEFT>, <RIGHT>, <UP>, and <DOWN>)
  • We use the roving tabIndex approach to track which tree item is selected.
    • This means that you can tab into the tree with focus landing on the last selected item, and you can change your selection and tab back out again without losing your place.
  • Selection tracks focus, so you don't have to manually select which item is displaying properties.
  • Pressing <RET> (<ENTER>) puts keyboard focus on the first focusable element in the selected item's properties page.

How Verified

Local build, devtools, Accessibility Insights, Narrator

@paulcam206
Copy link
Member Author

@anna-dingler / @jwoo-msft / @almedina-ms -- in addition to code review, please take a bit of time to play around with the new navigation model to make sure that it's reasonable to you. Please feel free to ask questions! :)

@paulcam206 paulcam206 force-pushed the paulcam/treeview-keyboard-nav branch from 29946d4 to 4fbf4a6 Compare November 21, 2023 20:48
@paulcam206 paulcam206 merged commit 7cf2239 into main Nov 21, 2023
@paulcam206 paulcam206 deleted the paulcam/treeview-keyboard-nav branch November 21, 2023 22:42
jwoo-msft added a commit that referenced this pull request May 1, 2024
* Fix `--blue` to be a _smidge_ darker (better contrast on `--black`) (#8745)

* Remove unnecessary `aria-required` property from container element (#8746)

* Add `hljs-comment` color to fix contrast (#8747)

* Switch from textblock to label in Input.Time sample (#8751)

* Add missing img alt text in a few spots (#8750)

* Slight tweak to common blue background/border color for contrast (#8748)

* Add missing `title` to `iframe` in blog post (#8754)

* [Samples] Update version for samples using `tooltip` (#8753)

* [Designer] Fix treeview control accessibility (#8757)

* fixed a11y issue (#8760)

* Update README.md (#8802)

* Added AdaptiveCards Template WinRT Component (#8805)

* added a new project file

* added test app and c# winrt component

* mostly working?

* fix impl

* updated nuget path

* added c# runtime component

* updated

* updated

* updated

* updated

* updated

* updated

* updated

* updated

* update

* removed winrt prject from AC and added C++ console sample app and the AC project to visualizer

* removed nuget config changes

---------

Co-authored-by: Paul Campbell <paulcam@microsoft.com>

* Jwoo/template winrt strong name (#8807)

* added a new project file

* added test app and c# winrt component

* mostly working?

* fix impl

* updated nuget path

* added c# runtime component

* updated

* updated

* updated

* updated

* updated

* updated

* updated

* updated

* update

* removed winrt prject from AC and added C++ console sample app and the AC project to visualizer

* removed nuget config changes

* added strong name

* added new property

---------

Co-authored-by: Paul Campbell <paulcam@microsoft.com>

* Added Package Info (#8811)

* added missing package info

* for sharing

* updated

* Update README.md (#8813)

* Add headingLevel to host config (#8814)

* Update action icon role to presentation (#8815)

* Update README.md (#8817)

Update release schedule for website

* Fix invalid color value (#8819)

* [NodeJS] Update hashing algorithm for webpack (#8835)

* Update hashing algorithm for webpack

Needed to unblock Node >16

* Tabs -> spaces

* [NodeJS] Add `ImageSet` class to enable styling (#8838)

* [NodeJS] Add optional overflow menu icon rendering (#8847)

* Remove tab index from nested inputs (#8848)

* [NodeJS] Add `grid` `ImageSet` style (#8845)

* Host old content from messagecardplayground on ac.io (#8866)

* Fix issue #8520 (#8870)

Updated AdaptiveTableCell to override the Type property

Co-authored-by: huberemanuel <emanuel.tesv@gmail.com>

* Update README.md (#8873)

Update icon for unsupported features

* Update README.md (#8859)

* Add tooltip for Arabic (#8890)

* [Website][A11y] Update keyboard nav for blog posts (#8891)

* Update keyboard nav for blog posts

* Add up/down navigation

* Navigate on enter

* Designer surface a11y updates (#8888)

* Designer surface a11y updates

* Update source/nodejs/adaptivecards-designer/src/peer-command.ts

Co-authored-by: Paul Campbell <paulcam@microsoft.com>

---------

Co-authored-by: Paul Campbell <paulcam@microsoft.com>

---------

Co-authored-by: Paul Campbell <paulcam@microsoft.com>
Co-authored-by: anna-dingler <98650930+anna-dingler@users.noreply.github.com>
Co-authored-by: Matej Simek <matej@simek.pro>
Co-authored-by: huberemanuel <emanuel.tesv@gmail.com>
jwoo-msft added a commit that referenced this pull request May 1, 2024
* Fix `--blue` to be a _smidge_ darker (better contrast on `--black`) (#8745)

* Remove unnecessary `aria-required` property from container element (#8746)

* Add `hljs-comment` color to fix contrast (#8747)

* Switch from textblock to label in Input.Time sample (#8751)

* Add missing img alt text in a few spots (#8750)

* Slight tweak to common blue background/border color for contrast (#8748)

* Add missing `title` to `iframe` in blog post (#8754)

* [Samples] Update version for samples using `tooltip` (#8753)

* [Designer] Fix treeview control accessibility (#8757)

* fixed a11y issue (#8760)

* Update README.md (#8802)

* Added AdaptiveCards Template WinRT Component (#8805)

* added a new project file

* added test app and c# winrt component

* mostly working?

* fix impl

* updated nuget path

* added c# runtime component

* updated

* updated

* updated

* updated

* updated

* updated

* updated

* updated

* update

* removed winrt prject from AC and added C++ console sample app and the AC project to visualizer

* removed nuget config changes

---------

Co-authored-by: Paul Campbell <paulcam@microsoft.com>

* Jwoo/template winrt strong name (#8807)

* added a new project file

* added test app and c# winrt component

* mostly working?

* fix impl

* updated nuget path

* added c# runtime component

* updated

* updated

* updated

* updated

* updated

* updated

* updated

* updated

* update

* removed winrt prject from AC and added C++ console sample app and the AC project to visualizer

* removed nuget config changes

* added strong name

* added new property

---------

Co-authored-by: Paul Campbell <paulcam@microsoft.com>

* Added Package Info (#8811)

* added missing package info

* for sharing

* updated

* Update README.md (#8813)

* Add headingLevel to host config (#8814)

* Update action icon role to presentation (#8815)

* Update README.md (#8817)

Update release schedule for website

* Fix invalid color value (#8819)

* [NodeJS] Update hashing algorithm for webpack (#8835)

* Update hashing algorithm for webpack

Needed to unblock Node >16

* Tabs -> spaces

* [NodeJS] Add `ImageSet` class to enable styling (#8838)

* [NodeJS] Add optional overflow menu icon rendering (#8847)

* Remove tab index from nested inputs (#8848)

* [NodeJS] Add `grid` `ImageSet` style (#8845)

* Host old content from messagecardplayground on ac.io (#8866)

* Fix issue #8520 (#8870)

Updated AdaptiveTableCell to override the Type property

Co-authored-by: huberemanuel <emanuel.tesv@gmail.com>

* Update README.md (#8873)

Update icon for unsupported features

* Update README.md (#8859)

* Add tooltip for Arabic (#8890)

* [Website][A11y] Update keyboard nav for blog posts (#8891)

* Update keyboard nav for blog posts

* Add up/down navigation

* Navigate on enter

* Designer surface a11y updates (#8888)

* Designer surface a11y updates

* Update source/nodejs/adaptivecards-designer/src/peer-command.ts

Co-authored-by: Paul Campbell <paulcam@microsoft.com>

---------

Co-authored-by: Paul Campbell <paulcam@microsoft.com>

* updated version

---------

Co-authored-by: Paul Campbell <paulcam@microsoft.com>
Co-authored-by: anna-dingler <98650930+anna-dingler@users.noreply.github.com>
Co-authored-by: Matej Simek <matej@simek.pro>
Co-authored-by: huberemanuel <emanuel.tesv@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants