-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
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
[Portal] Second iteration on the component #9613
Conversation
f203c0f
to
b720a49
Compare
<Portal container={this.container}>
<Typography>But I actually render here!</Typography>
</Portal> Very excited to see the ability to specify containers! Would love the ability to tap into that from the Popover component |
@gregnb You can with the "inheritance" of the properties. |
@oliviertassinari that's great! thanks for working on this |
b720a49
to
a84ed8f
Compare
0f7da21
to
9c411bf
Compare
9c411bf
to
ebeee5e
Compare
@oliviertassinari I don't think this is necessarily appropriate for For another, you're assuming we want the backdrop to show when the drawer is open, but that's not the case when we're using the drawer for a responsive Sidebar, which shouldn't interfere with the content when it's open on a large enough display. |
@jedwards1211 I'm not sure to follow. What's your conclusion? The Modal is only used by the temporary type of the Drawer. |
Sorry yeah, I wasn't used to the structure of the new docs, I discovered the different types in the demos section. |
@oliviertassinari Awesome! Can't wait to see this released, it's all we're waiting for to overhaul the UI on a project! |
@corytheboyd We release every weekend. You can start next week :). |
@oliviertassinari this PR removes I am using it to identify components selected in my Enzyme tests, which results broken for all components wrapped in this HOC. I could refactor to use unwrapped components only, but I was wondering if this is on purpose? Any reason for this removal? (ie should I do the same in my own HOC :-) ) Thanks! |
@pandaiolo The motivation is around developer experience. Let's take an example on the documentation website: How is displaying |
This React documentation section was introduced by @acdlite in reactjs/react.dev@e3d37fd. Maybe he can 💡 us. |
As well as @istarkov maintaining recompose, what do you think of this displayName logic change? |
Same story with the React warnings? What do you prefer between?
|
Ok I see, I agree it is more readable in the DOM and in the debugging output! However, I believe the displayName also has an identification purpose (for example in my use case in Enzyme selectors), which is defeated when the wrapping is removed, because it makes all wrapped components look alike. Also, is wrapped displayName that an issue? IMHO the visual improvement is not worth the loss of identification. Not sure if this is only my personal use case though, or if I should not use displayName for that! |
@pandaiolo I don't have a strong opinion on this change. Just not sure the value, we get out of it, is obvious.
No need for that, I have been updating the tests internally: -assert.strictEqual(wrapper.name(), 'withStyles(Paper)');
+assert.strictEqual(wrapper.type(), Paper); |
I also use function testUtil(wrapper, component, ...) {
const selector = component.type.displayName
wrapper.find(component)
// do some other things
} The above code example is the one that is broken by this PR in my case |
@pandaiolo Why don't you |
Also, you can use |
Sometimes // wrapper:
// <WrappingStuff>
// <WithChild prop="val" otherProp="other">{child}</withChild>
// </WrappingStuff />
itHas(wrapper, <WithChild prop="val" />)
// true I guess this would work: |
Or using MUI test-util const { displayName } = component.Naked ? unwrap(component) : component
wrapper.find(displayName) Edit: this only works for components, not elements like in my example... so there is no way to know on a HOC element what is the underlying component. |
Ok I did not yet find a way to resolve the above (minor) issue, but in the meantime just realized the true extent of the trouble in Enzyme debugging: const wrapper = shallow(<TestedComponent />)
wrapper.debug()
// Readable element tree Then, whenever tests fail, there is a very useful Any help to workaround this one very much appreciated! Edit: Real life example: <Aux>
<WithStyles dense={true} className="small" color="primary" disabled={false} onClick={[Function: value]}>
<pure(AddCircle) />
xxxx
</WithStyles>
<WithStyles open={true} classes={{...}}>
<WithStyles>
xxxx
</WithStyles>
<WithStyles classes={{...}}>
<Connect(WithTheme) includeXxxx={true} xxxId={51} onChange={[Function]} />
<h2>
Xxxx:
<span className="error">
(Warning: Xxx xx xx)
</span>
</h2>
<XxxInput fullWidth={true} name="xxx" value={10} onChange={[Function]} />
</WithStyles>
<WithStyles>
<WithStyles onClick={[Function: value]}>
Cancel
</WithStyles>
,
<WithTheme dialogTitle="Please confirm" text="Are you sure you want to xxxx?">
<WithStyles raised={true} color="primary" onClick={[Function: value]} disabled={false}>
Save
</WithStyles>
</WithTheme>
</WithStyles>
</WithStyles>
</Aux> See how WithStyle and WithTheme break displayName where recompose |
@pandaiolo I feel like we should revert and stick to the community convention (Unrelated to your testing issue). |
This pull-request revamp the implementation of the Portal and the Modal component.
Those two components are core and used by many more components: Dialog, Drawer, Snackbar, Popover, Menu, @select.
This effort might also fix some issues with the Select component, to investigate.
Closes #9528 as it's documented
Closes #9252 as we take the owner document into account
Closes #9248 as the new portal component behave correctly during the reconciliation
Closes #9207 as we take the owner document into account
Fix one part of #9474
Breaking changes
Some properties have been renamed:
The zIndex object has been updated to match the usage.