-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[core][Modal] Remove unnecessary manager
prop handling
#43867
[core][Modal] Remove unnecessary manager
prop handling
#43867
Conversation
Netlify deploy previewhttps://deploy-preview-43867--material-ui.netlify.app/ Bundle size reportDetails of bundle changes (Toolpad) |
manager
prop handling
@@ -85,15 +83,15 @@ function useModal(parameters: UseModalParameters): UseModalReturnValue { | |||
const handleOpen = useEventCallback(() => { | |||
const resolvedContainer = getContainer(container) || getDoc().body; | |||
|
|||
manager.add(getModal(), resolvedContainer); | |||
manager.add(getModal(), resolvedContainer as HTMLElement); |
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.
I had to cast it because the container
prop is typed as Element
(see here), but the modal manager methods expect HTMLElement
, which is correct. Also, document.body
(the default container) is an HTMLElement
. Changing the container
type in Portal
would be a breaking change, though we could also allow both Element
and HTMLElement
.
Can I get a review on 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.
Looks good. Not sure how we could get rid of the type casting without a breaking change.
This prop |
@oliviertassinari ouch. Sadly there wasn't a test to catch it. |
It's Ok, we can wait to see if people create issues. As far as I remember, the only use case left for this @atomiks As I understand it, in Base UI, the modal relies on Floating UI, https://master--base-ui.netlify.app/components/react-dialog/#nested-dialogs. And simply say: let's not fix it: https://github.com/mui/base-ui/blob/f51b2f4587df29a1f0d093745f4b8ed7439aba34/packages/mui-base/src/Dialog/Popup/DialogPopup.tsx#L33. So if we can get away with this in Material UI, great, we reduce the gap with Base UI. |
manager
prop handlingmanager
prop handling
manager
prop handlingmanager
prop handling
While reviewing a PR I noticed the
Modal
component anduseModal
hook don't have a manager prop, and we don’t exportuseModal
. This PR removes themanager
prop handling and directly uses the default modal manager, in turn improving type safety when using the modal manager methods.