Skip to content
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

Merged
merged 47 commits into from
Jul 28, 2019
Merged

Conversation

joshwooding
Copy link
Member

@joshwooding joshwooding commented Mar 10, 2019

Closes #12263

Capture d’écran 2019-07-08 à 11 09 02

Demo: https://deploy-preview-14827--material-ui.netlify.com/lab/tree-view/

TODO

  • Finish off the components
  • Tests
  • TypeScript
  • Demos

@joshwooding joshwooding force-pushed the tree-view branch 3 times, most recently from 43456c5 to 9b03209 Compare March 10, 2019 18:12
@mui-pr-bot
Copy link

mui-pr-bot commented Mar 10, 2019

No bundle size changes comparing bdb4baa...82898b1

Generated by 🚫 dangerJS against 82898b1

@mbrookes

This comment has been minimized.

Copy link
Member

@eps1lon eps1lon left a 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.

Copy link
Member

@oliviertassinari oliviertassinari left a 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.

@oliviertassinari oliviertassinari added new feature New feature or request component: tree view TreeView, TreeItem. This is the name of the generic UI component, not the React module! labels Mar 11, 2019
@joshwooding
Copy link
Member Author

@mbrookes I've changed the icons and tried to improve the spacing a little bit.

@eps1lon I've gotten rid of depth completely used nested lists

@joshwooding joshwooding force-pushed the tree-view branch 2 times, most recently from e489772 to 82898b1 Compare March 14, 2019 00:45
@mbrookes

This comment has been minimized.

@joshwooding

This comment has been minimized.

@jshearer
Copy link

jshearer commented Mar 18, 2019

This is looking great @joshwooding! Two questions:

reconciling the alignment of nodes with and without icons is going to be challenging

Is this talking about the difference in text alignment here?
Screen Shot 2019-03-18 at 2 46 44 PM

Not sure how to fix that.. maybe an empty IconButton?

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:

Screen Shot 2019-03-18 at 2 52 42 PM

@mbrookes

This comment has been minimized.

@oliviertassinari oliviertassinari changed the title [TreeView] Add TreeView component [TreeView] Add new component Apr 8, 2019
@oliviertassinari oliviertassinari added the priority: important This change can make a difference label May 12, 2019
@oliviertassinari oliviertassinari changed the base branch from next to master May 23, 2019 21:10
@mui-pr-bot
Copy link

mui-pr-bot commented Jun 2, 2019

@material-ui/core: parsed: +0.13% , gzip: +0.02%
@material-ui/lab: parsed: +7.61% , gzip: +6.94%

Details of bundle changes.

Comparing: 3f9fa1f...ce3e367

bundle parsed diff gzip diff prev parsed current parsed prev gzip current gzip
@material-ui/core +0.13% 🔺 +0.02% 🔺 331,368 331,796 90,896 90,912
@material-ui/core/Paper +0.01% 🔺 +0.04% 🔺 69,177 69,181 20,528 20,536
@material-ui/core/Paper.esm 0.00% +0.04% 🔺 62,047 62,050 19,208 19,216
@material-ui/core/Popper +0.01% 🔺 +0.04% 🔺 29,182 29,184 10,427 10,431
@material-ui/core/Textarea 0.00% -0.04% 5,759 5,759 2,367 2,366
@material-ui/core/TrapFocus 0.00% 0.00% 3,806 3,806 1,602 1,602
@material-ui/core/styles/createMuiTheme +0.01% 🔺 -0.09% 16,390 16,391 5,825 5,820
@material-ui/core/useMediaQuery 0.00% -0.08% 3,221 3,221 1,314 1,313
@material-ui/lab +7.61% 🔺 +6.94% 🔺 141,987 152,797 43,790 46,827
@material-ui/styles 0.00% +0.05% 🔺 51,886 51,888 15,339 15,346
@material-ui/system 0.00% +0.14% 🔺 15,761 15,761 4,380 4,386
Button 0.00% +0.01% 🔺 79,460 79,462 24,301 24,303
Modal 0.00% +0.08% 🔺 14,961 14,961 5,221 5,225
Portal 0.00% +0.06% 🔺 3,579 3,579 1,566 1,567
Rating 0.00% +0.03% 🔺 70,667 70,669 22,064 22,071
Slider +0.01% 🔺 0.00% 75,061 75,065 23,277 23,277
colorManipulator 0.00% 0.00% 3,904 3,904 1,543 1,543
docs.landing 0.00% 0.00% 52,056 52,056 13,831 13,831
docs.main 0.00% 0.00% 606,828 606,828 194,402 194,402
packages/material-ui/build/umd/material-ui.production.min.js 0.00% 0.00% 299,987 299,987 86,202 86,202

Generated by 🚫 dangerJS against ce3e367

@joshwooding joshwooding force-pushed the tree-view branch 2 times, most recently from 9f913a3 to ac11ab4 Compare June 2, 2019 18:54
@joshwooding

This comment has been minimized.

@joshwooding
Copy link
Member Author

Trying a different approach, and passing in an array. Please excuse the messy code... Working on the keyboard focus.

@joshwooding
Copy link
Member Author

joshwooding commented Jun 11, 2019

The TreeView should now have all keyboard support listed on the aria-practices page 🎉

Copy link
Member

@eps1lon eps1lon left a 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.

@joshwooding
Copy link
Member Author

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.

@eps1lon
Copy link
Member

eps1lon commented Jul 25, 2019

ave 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.

@KaRkY

This comment has been minimized.

@gespispace

This comment has been minimized.

@eps1lon
Copy link
Member

eps1lon commented Jul 25, 2019

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.

@joshwooding
Copy link
Member Author

The deployed netlify build?

Hmm, yeah doesn’t crash on my phone but the tree doesn’t work either 😅

Worked on my computer (windows chrome)

@joshwooding joshwooding requested a review from eps1lon July 27, 2019 15:32
@joshwooding
Copy link
Member Author

It was a broken merge :P

Copy link
Member

@eps1lon eps1lon left a 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}
Copy link
Member

@merceyz merceyz Jul 27, 2019

Choose a reason for hiding this comment

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

Suggested change
{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

Copy link
Member Author

@joshwooding joshwooding Jul 27, 2019

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

Copy link
Member

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.

Copy link
Member

@oliviertassinari oliviertassinari Jul 28, 2019

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 🙃.

Copy link
Member

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 😄

Copy link
Member

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?

Copy link
Member Author

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 😉

@oliviertassinari oliviertassinari merged commit e04b463 into mui:master Jul 28, 2019
@oliviertassinari
Copy link
Member

@joshwooding Really well done! A great step toward an awesome tree view component.

@felipezacani
Copy link

@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?

@oliviertassinari
Copy link
Member

@felipezacani You can follow mui/mui-x#9686.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: tree view TreeView, TreeItem. This is the name of the generic UI component, not the React module! new feature New feature or request priority: important This change can make a difference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement a TreeView component