-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[Material][Menu] Fix MenuPaper class composition precedence #37390
[Material][Menu] Fix MenuPaper class composition precedence #37390
Conversation
Netlify deploy previewhttps://deploy-preview-37390--material-ui.netlify.app/ @material-ui/core: parsed: +0.10% , gzip: +0.12% Bundle size report |
The failing test is because of the missing documentation for
That's why I haven't fixed it yet |
Yes, we should document them.
No, we don't want to add props we plan to remove :) It's best to teach developers to move to the new API
You can use
Yes, let's add all slots that makes sense in one go. |
Hey @mj12albert @mnajdova thanks for you comments! I implemented the suggested changes:
Please review when you have time to do so 😃 |
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.
Looks good 👍
slotProps={{ | ||
paper: { | ||
...PaperProps, | ||
classes: { | ||
...PaperProps.classes, | ||
root: classes.paper, | ||
}, | ||
}, | ||
}} |
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.
Hi @DiegoAndai
I found issue in here. When SelectInput
component pass slotProps
to this component. It will make slotProps
appear in other
variable at line 80. so we can lose value.
Here is example to give picture when it can happen.
<Select
...
MenuProps={{
slotProps: {
root: {
slotProps: {
backdrop: {
invisible: true,
},
},
},
},
}}
>
some item...
</Select>
I think you should extract slotProps
and merge at this line.
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.
Hi @ethaizone, you're correct!
I overlooked that when adding the slots
and slotProps
to the Popover
component, those would also be made available to the Menu component. If a user provides either, we would lose the values provided in the Menu component.
I created an issue and will be working on it next week: #37612
Thanks for spotting this 😊
Summary
This bug is closely related to #31013. The issue is that for the
Menu
component'sPaper
,PopoverPaper
styles are being applied on top ofMenuPaper
styles, when it should be the other way around.This is because the composition is not in the correct order: We use
as
to provide theMenuPaper
to thePopover
, soPopoverPaper
is built on top ofMenuPaper
, instead ofMenuPaper
being built on top ofPopoverPaper
, which causes:MenuPaper
that are also defined inPopoverPaper
to get overridden, which caused [material][Menu] Menu popover not leaving enough space to allow exiting out from long lists #36838MenuPaper
properties that are also defined inPopoverPaper
: CodesandboxSolution
To solve this, I implemented the
slots
andslotProps
props on thePopover
component with thepaper
key. With that, the new composition works as:PopoverPaper
is imported into theMenu
component's fileMenuPaper
is built on top ofPopoverPaper
MenuPaper
is passed toPopover
using thepaper
slotSome other changes that I did were
Menu
to useslotProps
instead ofPaperProps
, for consistency as we're now using the slot architecture.PaperProps
is still supported on thePopover
component.Popover
andMenu
Pending
Some questions I have that should be resolved before merging:
Popover
's newslots
andslotProps
props? Maybe we want to leave them as internal, although I don't see the harm in making them publiccomponents
andcomponentProps
equivalence? I didn't because slots are the new conventionpaper
slot, I had to refactor the way the props are passed to thePaper
component inside thePopover
to useuseSlotProps
. Every prop that I moved had a test associated (or I added it), except for the usage ofstyle: isPositioned ? paperSlotProps.style : { ...paperSlotProps.style, opacity: 0 }
which was added on this PR: [Popover] Fix paper position flash on open #34546. I could find a way to create a test for it, is there a way to test it or should I just leave it?root
key on theslots
prop as well? I didn't because it's not required for the fixPlease add any other suggestions you might have!
closses #36838