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

[Select] Migrate NativeSelect to emotion #24698

Merged
merged 15 commits into from Apr 8, 2021

Conversation

duganbrett
Copy link
Contributor

This PR migrates the NativeSelect and NativeSelect Input components to the new emotion format as a part of #24405.

@duganbrett
Copy link
Contributor Author

The styles from the NativeSelect file to the NativeSelectInput file to be closer to the components they were actually styling. If that's not wanted I can figure something else out.

@mui-pr-bot
Copy link

mui-pr-bot commented Jan 30, 2021

Details of bundle changes

@material-ui/core: parsed: +0.37% , gzip: +0.20%

Generated by 🚫 dangerJS against 5b4a4fe

@oliviertassinari oliviertassinari added the component: text field This is the name of the generic UI component, not the React module! label Jan 30, 2021
@oliviertassinari oliviertassinari self-assigned this Feb 23, 2021
@HofmannZ
Copy link

Would be great to have this in the next release 😁

@oliviertassinari oliviertassinari added the on hold There is a blocker, we need to wait label Mar 9, 2021
@oliviertassinari oliviertassinari removed the on hold There is a blocker, we need to wait label Apr 2, 2021
@oliviertassinari oliviertassinari removed their assignment Apr 2, 2021
@oliviertassinari
Copy link
Member

oliviertassinari commented Apr 2, 2021

@mnajdova Interested in taking this one on? It's a challenging one. I doubt the current solution is flying, it might need a maintainer to solve it.

@mnajdova
Copy link
Member

mnajdova commented Apr 5, 2021

@mnajdova Interested in taking this one on? It's a challenging one. I doubt the current solution is flying, it might need a maintainer to solve it.

Sure, will do

@mnajdova
Copy link
Member

mnajdova commented Apr 6, 2021

Ok, this is a bit tricky :)) From what I can see we should do the following:

  • Create NativeSelectRoot as a regular styled() component
  • Then from the input prop, we should use the type for the as prop, and use the input.props for spreading. This will be done instead of the React.clone. I know it's not the best but at this moment I don't have better idea.
  • Then inside the styled() component, we can use the classes from the NaticeSelectInput for styling, instead of the classes key.

I will try to implement these changes tomorrow on top of this PR.


Alternative would be to use the css utility, but I wouldn't like to introduce it just for this use-case as I am not sure how it would play with the overrides. If we agree that the previous proposal is bad, or if it won't work, this would be my second attempt at solving the problem.

@oliviertassinari
Copy link
Member

oliviertassinari commented Apr 6, 2021

@mnajdova The part that seemed tricky to me was that, since Select and NativeSelect aim to share most of the logic, we would need to migrate NativeSelect first, then export the component, for Select.

For the solution, instead of a classes prop, maybe we could provide a components prop. I doubt that we can remove the cloneElement because it seems that we need to add props before InputBase processes them.

@mnajdova
Copy link
Member

mnajdova commented Apr 7, 2021

@mnajdova The part that seemed tricky to me was that, since Select and NativeSelect aim to share most of the logic, we would need to migrate NativeSelect first, then export the component, for Select.

For the solution, instead of a classes prop, maybe we could provide a components prop. I doubt that we can remove the cloneElement because it seems that we need to add props before InputBase processes them.

I think it would be best if we convert the Select as well before merging this PR. I will branch from this branch and start converting the Select. I noticed some inconsistencies with the way of how the styles are defined, I will push those changes as part of this PR (FYI @duganbrett).

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Apr 7, 2021
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Apr 7, 2021
@mnajdova mnajdova added the component: select This is the name of the generic UI component, not the React module! label Apr 7, 2021
@mnajdova mnajdova changed the title [TextField] Migrate NativeSelect to emotion [Select] Migrate NativeSelect to emotion Apr 7, 2021
Copy link

@J-A-power J-A-power left a comment

Choose a reason for hiding this comment

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

  • 22

Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

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

I did some polishing and based the #25653 on top of this one. I don't think there is anything else we are missing. Actually, it was pretty straightforward to do it, we just needed to export the styles from the NativeSelectInput (I know you had those changes initially, but I moved them to the other PR so that it would be more obvious why those are needed.)

cc @oliviertassinari in case you are interested

@duganbrett
Copy link
Contributor Author

I did some polishing and based the #25653 on top of this one. I don't think there is anything else we are missing. Actually, it was pretty straightforward to do it, we just needed to export the styles from the NativeSelectInput (I know you had those changes initially, but I moved them to the other PR so that it would be more obvious why those are needed.

cc @oliviertassinari in case you are interested

Thanks for cleaning this one up and welcome back!

@mnajdova
Copy link
Member

mnajdova commented Apr 8, 2021

I am merging this one, we can revisit if anything else is necessary on #25653

@mnajdova mnajdova merged commit 0fc7823 into mui:next Apr 8, 2021
@@ -62,7 +62,7 @@ export const styles = (theme) => ({
},
/* Styles applied to the select component `selectMenu` class. */
selectMenu: {
height: 'auto', // Resets for multiple select with chips
height: 'auto', // Resets for multipile select with chips
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
height: 'auto', // Resets for multipile select with chips
height: 'auto', // Resets for multiple select with chips

},
}),
...(styleProps.selectMenu && {
height: 'auto', // Resets for multpile select with chips
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
height: 'auto', // Resets for multpile select with chips
height: 'auto', // Resets for multiple select with chips

@@ -1,2 +1,4 @@
export { default } from './NativeSelect';
export * from './NativeSelect';
export { default as nativeSelectClasses } from './nativeSelectClasses';
Copy link
Member

Choose a reason for hiding this comment

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

Convention with the other files

Suggested change
export { default as nativeSelectClasses } from './nativeSelectClasses';
export { default as nativeSelectClasses } from './nativeSelectClasses';

@@ -1 +1,3 @@
export { default } from './NativeSelect';
export { default as nativeSelectClasses } from './nativeSelectClasses';
Copy link
Member

Choose a reason for hiding this comment

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

Convention with the other files

Suggested change
export { default as nativeSelectClasses } from './nativeSelectClasses';
export { default as nativeSelectClasses } from './nativeSelectClasses';

@mnajdova
Copy link
Member

mnajdova commented Apr 9, 2021

@oliviertassinari requested changes addressed in 7b09f14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: select This is the name of the generic UI component, not the React module! component: text field This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants