Skip to content

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

Merged
merged 12 commits into from
Jun 12, 2025

Conversation

msmx-mnakagawa
Copy link
Collaborator

What I did

  • update markups
  • update classnames
  • improve a11y

Reference

https://v1.lightningdesignsystem.com/components/trees/

@msmx-mnakagawa msmx-mnakagawa self-assigned this Jun 2, 2025
Copy link

reg-suit bot commented Jun 2, 2025

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.

@msmx-mnakagawa msmx-mnakagawa requested a review from stomita June 2, 2025 07:23
@msmx-mnakagawa msmx-mnakagawa marked this pull request as ready for review June 2, 2025 07:23
@msmx-mnakagawa msmx-mnakagawa mentioned this pull request Jun 5, 2025
42 tasks
@@ -1,4 +1,10 @@
import React, { HTMLAttributes, createContext, FC, useMemo } from 'react';
import React, {
useId,
Copy link
Collaborator

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@stomita
I got it.
I created a PR #487 doing so.

Could you confirm it as well?

aria-controls=''
aria-hidden='true'
tabIndex={-1}
Copy link
Collaborator

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Same as #473 (comment).

Copy link
Collaborator

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@stomita
I got it. Thank you for pointing out.
In d4cb683, I removed tabIndexes that differ from the existing implementation.

type='icon-bare'
icon={icon}
iconSize='small'
iconSize='x-small'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Setting iconSize of toggling button to x-small makes the rendered result much smaller than the LDS catalog.

CleanShot 2025-06-06 at 08 50 29@2x

LDS doc:

CleanShot 2025-06-06 at 08 50 51@2x

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@stomita
I am so sorry that the doc uses the small size that is same as before. 🙇‍♂️
I reverted it in 91c971f.

onClick={onToggle}
title={typeof label === 'string' ? `Expand ${label}` : undefined}
Copy link
Collaborator

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@stomita
Though markups in the reference receive the titles..., I got it.
I removed the prop in f9c5166.

{ItemRender ? <ItemRender {...props} /> : label}
</a>
<span className='slds-has-flexi-truncate'>
{onLabelClick ? (
Copy link
Collaborator

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@stomita
I got it.
I unified them into the a tag in d9d94d4.

{onLabelClick ? (
<a
className='slds-tree__item-label slds-truncate'
tabIndex={-1}
Copy link
Collaborator

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@stomita
I added the title into the unified a tag in a97270c.

aria-controls=''
aria-hidden='true'
Copy link
Collaborator

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@stomita

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 the treeitem. aria-hidden="true" and tabindex="-1" must be placed on the toggle button.

Copy link
Collaborator

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@stomita
I got your opinion.
In 1ce5ad3, I removed area-hidden that may prevent a11y, just in case that the tree item doesn't always behave identically to the toggle button.

@msmx-mnakagawa msmx-mnakagawa requested a review from stomita June 6, 2025 08:50
aria-controls=''
aria-hidden='true'
tabIndex={-1}
Copy link
Collaborator

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.

aria-controls=''
aria-hidden='true'
Copy link
Collaborator

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.

@msmx-mnakagawa msmx-mnakagawa requested a review from stomita June 9, 2025 05:31
@stomita stomita merged commit c85f24a into support-slds-2 Jun 12, 2025
2 checks passed
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.

2 participants