-
-
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] Add new component #14827
[TreeView] Add new component #14827
Conversation
43456c5
to
9b03209
Compare
No bundle size changes comparing bdb4baa...82898b1 |
This comment has been minimized.
This comment has been minimized.
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.
Have you looked at https://www.w3.org/TR/wai-aria-practices-1.1/#TreeView? Maybe this helps when writing tests. Could solve two problems at once.
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.
It's a great start. Few concerns:
- What do you think of removing all the hover effects?
- Without looking at the accessibility of the component, I would guess it wasn't studied yet. Should use use ul > li > ul > li nesting? I don't know, to look into the state of the art resources.
e489772
to
82898b1
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This is looking great @joshwooding! Two questions:
Is this talking about the difference in text alignment here? Not sure how to fix that.. maybe an empty Also, will it be possible to rearrange the rendered components? For example, one requirement I have is to have the chevron to the right of the text, as opposed to the left, like this: |
This comment has been minimized.
This comment has been minimized.
@material-ui/core: parsed: +0.13% , gzip: +0.02% Details of bundle changes.Comparing: 3f9fa1f...ce3e367
|
9f913a3
to
ac11ab4
Compare
This comment has been minimized.
This comment has been minimized.
Trying a different approach, and passing in an array. Please excuse the messy code... Working on the keyboard focus. |
The TreeView should now have all keyboard support listed on the aria-practices page 🎉 |
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.
This is good to go as soon as we find out why https://deploy-preview-14827--material-ui.netlify.com/components/tree-view/ crashes and we settled on a name. Kind of prefer TreeItem
following the aria role.
I’ll have a look at the crash later, works on my version of chrome and my phone but crashes without an error on IE it seems. |
The deployed netlify build? Works on neither ubuntu chrome, windows chrome, android chrome, windows firefox nor IE 11. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
For feature requests please wait for the first release of this component. It will be released in the lab under an alpha version which gives us enough freedom to iterate over the API. |
Hmm, yeah doesn’t crash on my phone but the tree doesn’t work either 😅 Worked on my computer (windows chrome) |
It was a broken merge :P |
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.
Nice job
{...other} | ||
> | ||
<div className={classes.content} onClick={handleClick} ref={contentRef}> | ||
{stateIconsProvided ? <div className={classes.iconContainer}>{stateIcon}</div> : null} |
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.
{stateIconsProvided ? <div className={classes.iconContainer}>{stateIcon}</div> : null} | |
{stateIconsProvided && <div className={classes.iconContainer}>{stateIcon}</div>} |
I'm curious, is there a reason this syntax isn't used?
https://reactjs.org/docs/conditional-rendering.html#inline-if-with-logical--operator
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 really, was just following what I found in the code. Looks like the only time the above syntax is used is in CardHeader vs SvgIcon, LinearProgress, GridListTileBar, SnackbarContent. I'm happy with either syntax. Normally I prefer the one you suggested. Do either of you have a preference @oliviertassinari @eps1lon
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.
Second one is idiomatic react for conditional rendering. If this is the intention then we should use it. If the ternary is used for a reason other than conditional rendering it should be documented.
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.
React documents both: https://reactjs.org/docs/conditional-rendering.html#inline-if-with-logical--operator. I don't have a preference. I used to use &&
when first using React, nowadays, I only use ternaries. Maybe we should use &&
because it yields smaller code? However, if we use &&
we need to make sure we compare with a boolean! e.g. 0 && <span />
will display 0 🙃.
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.
It's not that important in the end IMO. Personally I would stick with strict equality checks and ternaries but as long as one pattern doesn't introduce more bugs than the other it really doesn't matter.
Or we introduce something like Bikeshed-Sundays were we batch those discussions 😄
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.
Valid point, it doesn't change anthing at the end of the day. As long as we use the same pattern everywhere, that we only have this discussion once, I'm happy. So all in in ternaries?
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.
Or we introduce something like Bikeshed-Sundays were we batch those discussions
@eps1lon 😆 I’m not sure I like the name though. What about Bikeshed Sundays
it’s soooo much cleaner 😉
@joshwooding Really well done! A great step toward an awesome tree view component. |
@oliviertassinari Not sure if I should post a bug or a support request. I'm trying to implement draggable TreeItems and the "draggable" prop is not being passed to the native element, as stated in the docs. Is this expected? |
@felipezacani You can follow mui/mui-x#9686. |
Closes #12263
Demo: https://deploy-preview-14827--material-ui.netlify.com/lab/tree-view/
TODO