Skip to content

Commit

Permalink
[material-ui][Modal] Remove unnecessary manager prop handling (mui#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeeshanTamboli authored Oct 2, 2024
1 parent ccb679c commit 16097c7
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions packages/mui-material/src/Modal/useModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function getHasTransition(children: UseModalParameters['children']) {

// A modal manager used to track and manage the state of open Modals.
// Modals don't open on the server so this won't conflict with concurrent requests.
const defaultManager = new ModalManager();
const manager = new ModalManager();
/**
*
* Demos:
Expand All @@ -42,8 +42,6 @@ function useModal(parameters: UseModalParameters): UseModalReturnValue {
container,
disableEscapeKeyDown = false,
disableScrollLock = false,
// @ts-ignore internal logic - Base UI supports the manager as a prop too
manager = defaultManager,
closeAfterTransition = false,
onTransitionEnter,
onTransitionExited,
Expand Down Expand Up @@ -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);

// The element was already mounted.
if (modalRef.current) {
handleMounted();
}
});

const isTopModal = React.useCallback(() => manager.isTopModal(getModal()), [manager]);
const isTopModal = () => manager.isTopModal(getModal());

const handlePortalRef = useEventCallback((node: HTMLElement) => {
mountNodeRef.current = node;
Expand All @@ -111,7 +109,7 @@ function useModal(parameters: UseModalParameters): UseModalReturnValue {

const handleClose = React.useCallback(() => {
manager.remove(getModal(), ariaHiddenProp);
}, [ariaHiddenProp, manager]);
}, [ariaHiddenProp]);

React.useEffect(() => {
return () => {
Expand Down

0 comments on commit 16097c7

Please sign in to comment.