Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

feat(Tree): integrate ARIA HTML design pattern #1488

Merged
merged 21 commits into from
Jun 17, 2019

Conversation

silviuaavram
Copy link
Collaborator

@silviuaavram silviuaavram commented Jun 11, 2019

https://www.w3.org/TR/wai-aria-practices-1.1/examples/treeview/treeview-2/treeview-2b.html

Added ARIA attributes to tree, treeitem and titles depending on their role. Items that are leaves will get treeitem role on the <a> (and role none on <li>) tag while expandable items will get treeitem role on the parent <li>.

Focus is handled differently: if leaf, focus will be on the <a>. If not, focus will be on the parent <li>.

Adapted UTs to match new specification. Also behavior UTs.

Not possible: to add focus tests for Left-Right behavior. I cannot focus anything on the tree with Enzyme.

WIP: adjust the behavior prop types.

@codecov
Copy link

codecov bot commented Jun 11, 2019

Codecov Report

Merging #1488 into master will decrease coverage by 0.2%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1488      +/-   ##
==========================================
- Coverage   73.43%   73.22%   -0.21%     
==========================================
  Files         822      822              
  Lines        6192     6193       +1     
  Branches     1778     1800      +22     
==========================================
- Hits         4547     4535      -12     
- Misses       1640     1653      +13     
  Partials        5        5
Impacted Files Coverage Δ
...ib/accessibility/Behaviors/Tree/subtreeBehavior.ts 100% <ø> (ø) ⬆️
packages/react/src/components/Tree/TreeTitle.tsx 70% <ø> (-16.37%) ⬇️
packages/react/src/components/Tree/Tree.tsx 93.33% <ø> (ø) ⬆️
...c/lib/accessibility/Behaviors/Tree/treeBehavior.ts 100% <100%> (ø) ⬆️
...b/accessibility/Behaviors/Tree/treeItemBehavior.ts 100% <100%> (ø) ⬆️
.../accessibility/Behaviors/Tree/treeTitleBehavior.ts 100% <100%> (ø) ⬆️
packages/react/src/components/Tree/TreeItem.tsx 76.31% <57.14%> (+22.74%) ⬆️
...ages/react/test/specs/behaviors/testDefinitions.ts 90.78% <0%> (-7.46%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update da02bc4...4b1f862. Read the comment docs.

@silviuaavram silviuaavram added accessibility All the Accessibility tasks and bugs should be tagged with this. 🚀 ready for review labels Jun 12, 2019
CHANGELOG.md Outdated Show resolved Hide resolved
}
},
setFocusToFirstChild: e => {
expandOrPassFocus: e => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: expandOrPassFocusToSubtree - wouldn't be more meanigful?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same sort of comment - as a client that is consuming this API, I don't understand what passFocus means. Would suggest shorter form of what @sophieH29 has suggested: expandOrFocusSubtree


_.invoke(this.props, 'onTitleClick', e, this.props)
},
collapseOrReceiveFocus: e => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may be even shorter: collapseOrFocus

Copy link
Contributor

@kuzhelov kuzhelov Jun 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

general thoughts on current actionHandlers API. As a client, frankly, it is completely unobvious for me how I should respond on collapseOrFocus action - specifically, what drives my confusion is this or part. What is the principle based on which I should select one or the other? It turns out that it is based on open prop value - but how I would know that?

Ok, and then the question for me, as a client, is - I have provided all the props to accessibility behavior, so I might expect that it has access to all of them. Then, why it doesn't just expose collapse or focus actions, because I expect that inner implementation might just check open prop I've provided to it - and then I, as a client, won't be required to solve this puzzle on my side.

Really think that we should adjust implementation of action handlers a bit, to make this decision for the client (not this PR - just general thoughts). This will result in much more convenient API

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jurokapsiar @sophieH29 @kolaps33 We can follow up.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree, action handlers can be extended to reflect this kind of situation - let's discuss how the API would look like

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -0,0 +1,49 @@
import { treeItemBehavior } from 'src/lib/accessibility'

describe('TreeItemBehavior.ts', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets omit extension from the test name

@@ -0,0 +1,49 @@
import { treeItemBehavior } from 'src/lib/accessibility'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest to introduce e2e tests for Tree's focus behavior - will be glad to assist if necessary.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

already created task for that, thanks!

@silviuaavram silviuaavram merged commit 7b96bd0 into master Jun 17, 2019
@delete-merged-branch delete-merged-branch bot deleted the feat/tree-aria-attributes branch June 17, 2019 08:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accessibility All the Accessibility tasks and bugs should be tagged with this. 🚀 ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants