-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[Menu] Deprecate *Props and complete slots
, slotProps
#44913
Conversation
Netlify deploy previewTextField: parsed: +0.32% , gzip: +0.26% Bundle size reportDetails of bundle changes (Toolpad) |
const resolvedTransitionProps = | ||
typeof externalForwardedProps.slotProps.transition === 'function' | ||
? externalForwardedProps.slotProps.transition(ownerState) | ||
: externalForwardedProps.slotProps.transition; |
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.
Should we use mergeSlotProps
here?
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.
mergeSlotProps
does not concat event handlers, if users provide onEntering
it will replace the handleEntering
of the Menu. That's why we need to check for typeof function here so that we can:
onEntering: (...args) => {
handleEntering(...args); // menu logic
resolvedTransitionProps?.onEntering?.(...args); // user logic
},
I don't want to go that far to make mergeSlotProps
handle event handlers concatenation because it might effect the performance because the logic will need to loop all slotProps to identify which prop is an event handler (starting with on*
).
typeof slotProps.backdrop === 'function' | ||
? slotProps.backdrop(ownerState) | ||
: slotProps.backdrop, |
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.
Should we use mergeSlotProps
here?
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.
No because it will produce a different behavior. The reason to check for typeof function is to use the ownerState
of the Menu, not the Popover.
const transitionProps = | ||
typeof slotProps?.transition === 'function' | ||
? slotProps.transition(ownerState) | ||
: slotProps?.transition; |
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.
Should we use mergeSlotProps
here?
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.
Same reason as the above comment.
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.
Thanks for the explanations @siriwatknp
Part of #41281
MenuListProps
andTransitionProps
.slots.transition
andslots.list