-
Notifications
You must be signed in to change notification settings - Fork 4
✨(tree-view) load children on keyboard navigation and simplify toggle #115
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
base: main
Are you sure you want to change the base?
Conversation
replace arrow click with node.toggle and trigger load on open via useEffect Signed-off-by: Cyril <c.gromoff@gmail.com>
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.
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(); |
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.
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.
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.
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
I agree, test suites will be nice |
3340749
to
de50607
Compare
|
||
## [Unreleased] | ||
|
||
## 0.16.2 |
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.
Should be under unreleased like for Docs
.
## 0.16.2 |
if (timeoutRef.current && !isOver) { | ||
clearTimeout(timeoutRef.current); | ||
} |
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 it is better pattern to do like that.
if (timeoutRef.current && !isOver) { | |
clearTimeout(timeoutRef.current); | |
} | |
return () => { | |
if (timeoutRef.current) { | |
clearTimeout(timeoutRef.current); | |
} | |
}; |
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