Skip to content
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

[ModalUnstyled] Define ownerState and slot props' types #32901

Merged
merged 11 commits into from
Jun 16, 2022

Conversation

michaldudak
Copy link
Member

  • Defined types for ModalUnstyled's ownerState and its slots.
  • Renamed types and files according to [RFC] Code organization in @mui/base #31415
  • Moved BackdropComponent and BackdropProps to components.Backdrop and componentsProps.backdrop, respectively

After #32739 is merged, yarn proptypes needs to be run again - this will solve issues with missing fields in API docs.

@michaldudak michaldudak requested a review from a team May 25, 2022 11:02
@mui-bot
Copy link

mui-bot commented May 25, 2022

Details of bundle changes

Generated by 🚫 dangerJS against 39dfb79

@michaldudak michaldudak added typescript component: modal This is the name of the generic UI component, not the React module! package: base-ui Specific to @mui/base labels May 25, 2022
@@ -111,8 +113,8 @@ const Modal = React.forwardRef(function Modal(inProps, ref) {
ownerState: { ...componentsProps.root?.ownerState },
}),
},
backdrop: BackdropProps ?? componentsProps.backdrop,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we merge these two for now?

@@ -237,23 +226,6 @@ Modal.propTypes /* remove-proptypes */ = {
* @default false
*/
keepMounted: PropTypes.bool,
/**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is suspicious, why were these removed? Should we update the props interface for the @mui/material's Modal?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were removed in an older commit. After #32739 was merged, these lines were restored.

@@ -271,7 +272,7 @@ const ModalUnstyled = React.forwardRef(function ModalUnstyled(props, ref) {
aria-hidden
open={open}
onClick={handleBackdropClick}
{...BackdropProps}
{...backdropProps}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't have to be part of this pr, but looks like we are missing spreading ownerState here, no?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well spotted! I changed the code to use the same pattern as elsewhere (with appendOwnerState)

});

const styledModal = (
<ModalUnstyled open components={{ Root }}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add test-case for the Backdrop component too

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<ModalUnstyled open components={{ Root }}>
<ModalUnstyled open components={{ Root, Backdrop }}>

@@ -295,6 +295,7 @@ Dialog.propTypes /* remove-proptypes */ = {
'aria-labelledby': PropTypes.string,
/**
* A backdrop component. This prop enables custom backdrop rendering.
* @deprecated Use `components.Backdrop` instead.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we update the component itself to use the components.Backdrop and the componentsProps.backdrop too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point!

Copy link
Member

@oliviertassinari oliviertassinari Jun 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michaldudak michaldudak requested a review from mnajdova June 1, 2022 08:19
Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check these final comments, I think we removed adding the as prop and are not handling it anywhere now.

role="presentation"
{...rootProps}
{...(!isHostComponent(Root) && {
as: component,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this can create breaking change for the Material UI component, can we handle it there?

ownerState: { ...componentsProps.root?.ownerState },
}),
},
root: componentsProps.root,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add the logic for the components & as prop here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Good point. I added it here.

Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one final comment, the rest looks good.

});

const styledModal = (
<ModalUnstyled open components={{ Root }}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<ModalUnstyled open components={{ Root }}>
<ModalUnstyled open components={{ Root, Backdrop }}>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: modal This is the name of the generic UI component, not the React module! package: base-ui Specific to @mui/base typescript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants