-
Notifications
You must be signed in to change notification settings - Fork 538
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
TreeView: Add support for leading and trailing visuals #2383
Conversation
🦋 Changeset detectedLatest commit: 4787ccb The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
size-limit report 📦
|
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.
Looks good. Only comments are about examples and stories - not the actual implementation.
docs/content/TreeView.mdx
Outdated
</TreeView.LeadingVisual> | ||
Avatar.tsx | ||
<TreeView.TrailingVisual> | ||
<StyledOcticon icon={DiffAddedIcon} color="success.fg" /> |
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.
Since these trailing visuals are used to visually communicate diff status, I'm pretty sure they should have an aria-label
.
cc @ericwbailey
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.
That makes sense. How should the aria-label
for the trailing visual impact the aria-label
of the treeitem?
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.
Currently, the aria-label would be Avatar.tsx added
. That seems correct but I'd love confirmation from @ericwbailey.
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 updated the docs and stories to include aria-label
on these trailing visuals 👍
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.
Sorry to get to this after merging. I try to avoid using aria-label
on non-interactive elements, given their mixed support. In the API guidance I am recommending content that uses both aria-hidden="true"
and a sr-only
class applied to it.
In addition to the mixed support concern, we're also going to be using the text string to construct aria-labeledby
announcements for the relevant TreeView node.
{childrenWithoutSubTree} | ||
<Slots> | ||
{slots => ( | ||
// QUESTION: How should leading and trailing visuals impact the aria-label? |
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.
Which aria-label are you talking about?
I don't think we'll need content that is accessible to assistive tech for most trailing and leading visuals.
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 thinking about the aria-label
for the element with role=treeitem
.
const DirectoryIcon = () => { | ||
const {isExpanded} = React.useContext(ItemContext) | ||
const icon = isExpanded ? FileDirectoryOpenFillIcon : FileDirectoryFillIcon | ||
// TODO: Use correct color |
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'll open a @primer/primitives PR with the folder color.
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.
@@ -10,63 +10,98 @@ description: A hierarchical list of items where nested items can be expanded and | |||
### File tree navigation without directory links |
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.
Could we get an example (and maybe a story?) showing how to use the isExpanded
render prop to set different icons for expanded and collapsed states.
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.
Great idea 👍 Let me know if the docs I added make sense
Summary
Adds
TreeView.LeadingVisual
,TreeView.TrailingVisual
, andTreeView.DirectoryIcon
components to support leading and trailing visuals:👉 Try it out
Open questions
Merge checklist
Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.