Skip to content

Conversation

Ovgodd
Copy link
Collaborator

@Ovgodd Ovgodd commented Sep 18, 2025

Fix TreeViewItem keyboard toggling for child nodes: children has to load when toggling via keyboard.
Refactors arrow click to use node.toggle() instead of handleClick.

The issue in docs app is that fold/unfold via keyboard don’t work initially when multiple subdocs are present, a mouse click is required first before keyboard toggling became functional.

See: suitenumerique/docs#1388

replace arrow click with node.toggle and trigger load on open via useEffect

Signed-off-by: Cyril <c.gromoff@gmail.com>
@Ovgodd Ovgodd requested a review from AntoLC September 18, 2025 12:18
@Ovgodd Ovgodd self-assigned this Sep 18, 2025
@Ovgodd Ovgodd added the Accessibility Accessibility Update label Sep 18, 2025
Copy link
Contributor

@AntoLC AntoLC left a comment

Choose a reason for hiding this comment

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

Not your fault, but without test suite it is quite complicated to test the patch, we have to modify Story book to succeed to create the perfect environnement.

Hard to see if we don't introduce regression as well.

<span
onClick={(e) => {
e.stopPropagation();
void handleClick();
Copy link
Contributor

Choose a reason for hiding this comment

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

We can remove totally the function handleClick, inside handleOver you can replace void handleClick(); by node.open();. We don't need to memoized handleOver neither, it can directly go inside the useEffect under I think.

Copy link
Collaborator Author

@Ovgodd Ovgodd Sep 22, 2025

Choose a reason for hiding this comment

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

Yes, you’re right.

In this case, useCallback isn’t needed.
We can put the logic directly in the useEffect.

Another thing : React 19’s compiler will help with memoization in many cases, so we don't need memoize function for many cases,

good catch

@Ovgodd
Copy link
Collaborator Author

Ovgodd commented Sep 22, 2025

Not your fault, but without test suite it is quite complicated to test the patch, we have to modify Story book to succeed to create the perfect environnement.

Hard to see if we don't introduce regression as well.

I agree, test suites will be nice

@Ovgodd Ovgodd requested a review from AntoLC September 22, 2025 09:15
@Ovgodd Ovgodd force-pushed the fix/tree-view-arrow-click-behavior branch from 3340749 to de50607 Compare September 22, 2025 09:18

## [Unreleased]

## 0.16.2
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be under unreleased like for Docs.

Suggested change
## 0.16.2

Comment on lines +66 to +68
if (timeoutRef.current && !isOver) {
clearTimeout(timeoutRef.current);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is better pattern to do like that.

Suggested change
if (timeoutRef.current && !isOver) {
clearTimeout(timeoutRef.current);
}
return () => {
if (timeoutRef.current) {
clearTimeout(timeoutRef.current);
}
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accessibility Accessibility Update
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants