-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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] Change focus management to aria-descendant #21592
Conversation
@material-ui/lab: parsed: -0.90% 😍, gzip: -0.84% 😍 |
72bcf15
to
7ad7db0
Compare
9556ff7
to
1ebc907
Compare
Current thoughts using the old descendants allows us to separate the component API and the component that renders to the DOM. This is nice for lots of reasons but probably needs more thought but it makes it easier to support virtualisation and drag and drop. I've tested it using the react@next test mode and it passed so hopefully won't be a problem. |
* @param {object} event The event source of the callback | ||
* @param {string} value of the focused node. | ||
*/ | ||
onNodeFocus?: (event: React.ChangeEvent<{}>, nodeId: string) => void; |
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 you can no longer use onFocus to track focus to nodes thought I should add this.
(id) => { | ||
const nodes = getNodesToRemove(id); |
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.
So much cleaner. Each node only cares about itself now and we get rid of a lot of looping :)
}; | ||
|
||
return ( | ||
<TreeViewContext.Provider | ||
value={{ | ||
icons: { defaultCollapseIcon, defaultExpandIcon, defaultParentIcon, defaultEndIcon }, | ||
focus, | ||
focusFirstNode, |
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.
A lot less stuff being passed through context is great for readability and potentially performance :)
440ab04
to
70e3084
Compare
Nice to see the size drop after the other PR was merged :) |
70e3084
to
e76c197
Compare
Closed in favour of #21695 Will investigate change descendants in another PR. |
Opened for visibility. Built on: #21574
Closes #20204
Closes #20097
Allows us to have more flexibility in the future and simplifies TreeItem. Since I was changing a lot of the tests due to the focus change I refactored them all to use
screen
and removed all uses ofcontainer
.