-
-
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
[Base] Allow useSlotProps to receive undefined elementType #35192
[Base] Allow useSlotProps to receive undefined elementType #35192
Conversation
|
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.
Could you please create a test that verifies the behavior you added?
otherProps: OtherProps, | ||
ownerState: OwnerState, | ||
): AppendOwnerStateReturnType<ElementType, OtherProps, OwnerState> { | ||
if (isHostComponent(elementType)) { | ||
if (elementType && isHostComponent(elementType)) { |
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.
There's no need to append ownerState when ElementType is not defined.
if (elementType && isHostComponent(elementType)) { | |
if (elementType === undefined || isHostComponent(elementType)) { |
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 quick review! My bad, fixed it.
@@ -29,7 +29,7 @@ export type AppendOwnerStateReturnType< | |||
/** | |||
* Appends the ownerState object to the props, merging with the existing one if necessary. | |||
* | |||
* @param elementType Type of the element that owns the `existingProps`. If the element is a DOM node, `ownerState` is not applied. | |||
* @param elementType Type of the element that owns the `existingProps`. If the element is undefined or a DOM node, `ownerState` is not applied. |
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.
nit: the DOM node case is likely much more common, so I'd put it first.
* @param elementType Type of the element that owns the `existingProps`. If the element is undefined or a DOM node, `ownerState` is not applied. | |
* @param elementType Type of the element that owns the `existingProps`. If the element is a DOM node or undefined, `ownerState` is not applied. |
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 your contribution!
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.
It's a great first pull request on MUI, thank you for working on it! 👌
To make this PR #34793 possible, we agreed to extend useSlotProps with the support for undefined component types.
See this comment: #34793 (comment)