-
-
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
[Modal] Convert code to typescript #34793
[Modal] Convert code to typescript #34793
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.
Thanks for your work! There is a couple of changes needed before we can merge it.
@@ -249,7 +274,7 @@ const ModalUnstyled = React.forwardRef(function ModalUnstyled(props, ref) { | |||
ownerState, | |||
}); | |||
|
|||
const BackdropComponent = components.Backdrop; | |||
const BackdropComponent = components?.Backdrop || 'div'; |
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.
Why the || div
is added? This changes the default behavior and makes the backdrop always visible.
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.
useSlotProps
expects elementType
not to be undefined, so I added this as a default that seemed reasonable.
After checking other usages, maybe this would be better?
const BackdropComponent = components?.Backdrop || 'div'; | |
const BackdropComponent = components?.Backdrop ?? 'div'; |
If not, I need some Help resolving this.
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.
In this case, it seems it's necessary to extend useSlotProps with the support for undefined
component types. It should return an empty object then. This could be done in a separate PR to keep things focused. Would you like to work on it as well?
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.
Yes, I would love to do that.
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.
All right, so let's get that one done first and then we can go back to the Modal.
Thank you for your review, I will work on these on the weekend! |
|
# Conflicts: # packages/mui-base/src/ModalUnstyled/ModalUnstyled.tsx
I can't seem to get these last two type errors solved. Maybe someone could help me with them. |
Do you need any help resolving merge conflicts or making CI checks green? Regarding type errors, you need to cast the |
# Conflicts: # packages/mui-base/src/ModalUnstyled/ModalUnstyled.tsx
I did what you suggested but this somehow gave me even more errors in the |
You have done the majority of hard work, thanks! The remaining issue was missing types of |
Thank you so much for your patience and help, I really appreciate it! |
Thank you for contributing! Feel free to tackle any other issues. |
closes #34716