New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a11y support for the tree-control #36459
Conversation
Test Results SummaryCommit SHA: ef34a9b
To view the full API test report, click here. To view the full E2E test report, click here. To view all test reports, visit the WooCommerce Test Reports Dashboard. |
2b9739d
to
e5a813a
Compare
e5a813a
to
7fd9f31
Compare
476a3f9
to
74b49c0
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## trunk #36459 +/- ##
==========================================
- Coverage 46.7% 46.7% -0.0%
- Complexity 17183 17188 +5
==========================================
Files 429 429
Lines 64799 64820 +21
==========================================
Hits 30251 30251
- Misses 34548 34569 +21
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job. It's testing well on the storybook and the aria attributes seem correct.
I'm just wondering if there wasn't a way of doing this without relying on CSS and DOM manipulation, but I don't have any suggestions regarding that, so I just left a small suggestion.
return null; | ||
} | ||
|
||
const step = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can move this to outside the function as it's a constant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put it there because I intentionally wanted to hide the step
variable from being used outside of that function.
But I don't have a strong opinion for this anyway. It's done now!
@nathanss What specific CSS and DOM manipulation are you referring to? |
Significance: minor | ||
Type: dev | ||
|
||
Add a11y support for the tree-control |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of tree-control
, consider Tree
component
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @mattsherman. It's done now.
@mattsherman I guess it's not "manipulation" since we're not changing the values, just querying them. I'm referring to all the document queries inside the |
Thanks for the clarification. I can see how these DOM queries could be non-ideal, as if the rendered DOM were changed elsewhere in code, these queries would need to be changed. What would a more "React way" look like to you? |
currentHeading: HTMLDivElement | ||
): NodeListOf< HTMLDivElement > | undefined { | ||
const rootTree = currentHeading.closest< HTMLDivElement >( | ||
'.experimental-woocommerce-tree--level-1' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that -1
here correct? Can't that number change depending on the situation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that -1 here correct?
Yes it's. This --level-1
refers to the nesting level of the tree. So that all subtrees have their parent level + 1 like --level-2
, --level-3
... going from the root to the leafs.
@mattsherman I guess the main thing that CSS is solving in For the focus, each tree item could have a This could potentially make the performance worse. Maybe it's OK to rely on CSS a little bit, especially in a component's implementation. This all seems to be encapsulated inside the |
Yes that was my first approach, trying to use a context but the tree is a complex structure that we should use carefully. After trying to perform across tree-items operations thinks becomes heavy to manage. Like focusing the first child of an expanded subtree, or focus the first ancestor or successor, ... Also, the idea was to keep thinks scoped to each own custom hook so that we can replace them easily when needed, another reason why the hooks are very isolated. Well, if we could find a way to deal with all the scenarios without impacting performance, I'm definitely in! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm OK with the current code and it seems to work well, so I'm approving it
Depends on #36590
All Submissions:
Changes proposed in this Pull Request:
Depends on #36480
Partialy closes #35851
How to test the changes in this Pull Request:
http://localhost:6007/?path=/story/woocommerce-admin-experimental-treecontrol--selection-multiple
Other information:
pnpm --filter=<project> changelog add
?FOR PR REVIEWER ONLY: