-
Notifications
You must be signed in to change notification settings - Fork 87
Update Tree
and TreeNode
for SLDS2
#473
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
Conversation
reg-suit detected visual differences. Check this report, and review them. 🔴 🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵 What do the circles mean?The number of circles represent the number of changed images.🔴 : Changed items, ⚪ : New items, ⚫ : Deleted items, and 🔵 Passed items How can I change the check status?If reviewers approve this PR, the reg context status will be green automatically. |
@@ -1,4 +1,10 @@ | |||
import React, { HTMLAttributes, createContext, FC, useMemo } from 'react'; | |||
import React, { | |||
useId, |
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.
If you are going to use useId
, be sure to remove 17.0 from the peerDependency in package.json.
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.
src/scripts/TreeNode.tsx
Outdated
aria-controls='' | ||
aria-hidden='true' | ||
tabIndex={-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.
Setting tabIndex to -1 should be carefully determined, as the current implementation might be utilizing the node to be focused by the users.
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.
Same as #473 (comment).
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.
@msmx-mnakagawa
As the current tree item toggle is allowing tab focus, It would break existing implementations.
If you are going to change it, be care about the effects caused by the change.
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.
src/scripts/TreeNode.tsx
Outdated
type='icon-bare' | ||
icon={icon} | ||
iconSize='small' | ||
iconSize='x-small' |
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.
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.
src/scripts/TreeNode.tsx
Outdated
onClick={onToggle} | ||
title={typeof label === 'string' ? `Expand ${label}` : undefined} |
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.
Implicit title
setting would not be required in the lib layer.
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.
src/scripts/TreeNode.tsx
Outdated
{ItemRender ? <ItemRender {...props} /> : label} | ||
</a> | ||
<span className='slds-has-flexi-truncate'> | ||
{onLabelClick ? ( |
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 this switch required ? It might be ok with current '' rendering even if there is not defined onLabelClick handler.
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.
src/scripts/TreeNode.tsx
Outdated
{onLabelClick ? ( | ||
<a | ||
className='slds-tree__item-label slds-truncate' | ||
tabIndex={-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.
Add title
prop if you are going to show the label value automatically like here
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.
src/scripts/TreeNode.tsx
Outdated
aria-controls='' | ||
aria-hidden='true' |
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.
The aria-hidden
is set to true, even it is surely displayed.
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.
Well, the reference says that adding aria-hidden="true"
and tabindex="-1"
is must thing.
Following this spec, how can we do...?
https://v1.lightningdesignsystem.com/components/trees/#About-Trees
In our example, we are using a chevron icon on tree branches to help indicate to the user what action clicking the tree branch will perform, whether opening or closing it. The effect of rotating the icon 90° to indicate open/closed status is achieved by applying the ARIA attribute
aria-expanded
to thetreeitem
.aria-hidden="true"
andtabindex="-1"
must be placed on the toggle button.
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.
@msmx-mnakagawa
In the LDS documentation, this toggle button is used solely to open or close a tree node, and the same action is triggered when the node itself is clicked. In other words, the LDS example assumes that the tree item behaves identically to the toggle button, which may not always be guaranteed. If the toggle button is not exposed to assistive technologies, users with disabilities have no way to determine or control whether the node is open or closed — especially if there is no guarantee that clicking the node itself performs the same action as the toggle button.
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.
src/scripts/TreeNode.tsx
Outdated
aria-controls='' | ||
aria-hidden='true' | ||
tabIndex={-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.
@msmx-mnakagawa
As the current tree item toggle is allowing tab focus, It would break existing implementations.
If you are going to change it, be care about the effects caused by the change.
src/scripts/TreeNode.tsx
Outdated
aria-controls='' | ||
aria-hidden='true' |
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.
@msmx-mnakagawa
In the LDS documentation, this toggle button is used solely to open or close a tree node, and the same action is triggered when the node itself is clicked. In other words, the LDS example assumes that the tree item behaves identically to the toggle button, which may not always be guaranteed. If the toggle button is not exposed to assistive technologies, users with disabilities have no way to determine or control whether the node is open or closed — especially if there is no guarantee that clicking the node itself performs the same action as the toggle button.
What I did
Reference
https://v1.lightningdesignsystem.com/components/trees/