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

[Popover] ModalClasses prop regression #16441

Closed
jeffshaver opened this issue Jul 1, 2019 · 9 comments
Closed

[Popover] ModalClasses prop regression #16441

jeffshaver opened this issue Jul 1, 2019 · 9 comments
Assignees
Labels

Comments

@jeffshaver
Copy link

On Popover, we were using the ModalClasses prop to pass a class to the div that gets mounted for the Modal.

This is broken now. I am not 100% sure on when this regression occurred (maybe on the functional rewrite?).

The problem (I think) is that Modal doesn't pull off classes as a known prop, it just gets spread using {...other}. Which means the div gets an attribute called classes and its value is [Object object]. I think the solution is to have modal pull of classes and as a prop.

Another alternative would be to give Popover a ModalProps prop instead of ModalClasses and then spread that onto the Modal component.

Second solution seems more flexible.

  • [ x ] This is not a v0.x issue.
  • [ x ] I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior 🤔

The div that Modal creates should have the correct classnames.

Current Behavior 😯

The div that Modal creates gets a classes="[Object object] attribute

Steps to Reproduce 🕹

Link: https://codesandbox.io/s/create-react-app-with-typescript-787wb

  1. All you have to do is inspect the popover on the demo and see that the attribute is created wrong

Context 🔦

I am trying to pass a class name to the div that the Modal component creates

Your Environment 🌎

Tech Version
Material-UI v4.1.2
React 16.8.19
Browser Chrome 74.0.3729.169
TypeScript 3.5.2
@oliviertassinari oliviertassinari self-assigned this Jul 1, 2019
@oliviertassinari
Copy link
Member

oliviertassinari commented Jul 1, 2019

@jeffshaver Your issue is very similar to #16442. The classes API was removed in #15466.

You can use the class name API directly.

-<Popover open={true} ModalClasses={{ root: classes.test }} />
+<Popover open={true} className={{classes.test}} />

Does it solve your issue?

@francoiscabrol
Copy link

@oliviertassinari it solved the issue for me but I had to add an important in the css to override the z-index.

@oliviertassinari
Copy link
Member

@francoiscabrol Right, same issue as #16442.

@jedwards1211
Copy link
Contributor

I guess this wasn't released as a breaking change because the new React warnings are just warnings?

@jedwards1211
Copy link
Contributor

jedwards1211 commented Dec 12, 2019

AFAICT I'm going to have to have a conditional on the version number of @material-ui/core to support all versions of v4 in material-ui-popup-state now without React warnings...kinda not cool

@oliviertassinari
Copy link
Member

I would recommend dropping v3 support.

@jedwards1211
Copy link
Contributor

jedwards1211 commented Dec 12, 2019

Okay, I was getting confused because somehow no warnings were showing about the ModalClasses prop getting passed to a <div> in @material-ui/core/4.0.2. FWIW it's pretty surprising and confusing that classes passed to Popover affects the Popover, but the className prop goes through to the Modal.

@jedwards1211
Copy link
Contributor

@oliviertassinari I was thinking I would have to do different things for different sub-versions of v4, but fortunately I was confused, sorry.

@oliviertassinari
Copy link
Member

Yeah, you are right classes doesn't inherit, while className does.

@oliviertassinari oliviertassinari added component: Popover The React component. and removed component: modal This is the name of the generic UI component, not the React module! labels Apr 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants