Skip to content

Commit 7a444a1

Browse files
authored
refactor(Modal): remove workaround for open prop (#7856)
1 parent f981f64 commit 7a444a1

File tree

1 file changed

+7
-22
lines changed

1 file changed

+7
-22
lines changed

packages/main/src/components/Modals/index.tsx

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
'use client';
22

3-
import { useIsomorphicLayoutEffect, useSyncRef } from '@ui5/webcomponents-react-base';
43
import type { MutableRefObject } from 'react';
54
import { createRef, useSyncExternalStore } from 'react';
65
import { createPortal } from 'react-dom';
76
import { getRandomId } from '../../internal/getRandomId.js';
8-
import type { IModal } from '../../internal/ModalStore.js';
97
import { ModalStore } from '../../internal/ModalStore.js';
108
import type { DialogDomRef, DialogPropTypes } from '../../webComponents/Dialog/index.js';
119
import { Dialog } from '../../webComponents/Dialog/index.js';
@@ -219,24 +217,6 @@ function showToastFn(props: ToastPropTypes, container?: Element | DocumentFragme
219217
};
220218
}
221219

222-
// todo: remove this once it's possible initializing popovers with `open=true` again
223-
function ModalComponent({ modal }: { modal: IModal }) {
224-
const [componentRef, modalsRef] = useSyncRef(modal.ref);
225-
useIsomorphicLayoutEffect(() => {
226-
const modalElement = modalsRef.current as PopoverDomRef;
227-
if (modalElement) {
228-
requestAnimationFrame(() => {
229-
modalElement.open = true;
230-
});
231-
}
232-
}, []);
233-
234-
const { open: _0, ...props } = modal.props;
235-
236-
// @ts-expect-error: ref is supported by all supported modals
237-
return <modal.Component {...props} ref={componentRef} data-id={modal.id} />;
238-
}
239-
240220
/**
241221
* Utility class for opening modals in an imperative way.
242222
*
@@ -255,9 +235,14 @@ export function Modals() {
255235
{modals.map((modal) => {
256236
if (modal?.Component) {
257237
if (modal.container) {
258-
return createPortal(<ModalComponent modal={modal} key={modal.id} />, modal.container);
238+
return createPortal(
239+
// @ts-expect-error: ref is supported by all supported modals
240+
<modal.Component {...modal.props} ref={modal.ref} key={modal.id} data-id={modal.id} />,
241+
modal.container,
242+
);
259243
}
260-
return <ModalComponent modal={modal} key={modal.id} />;
244+
// @ts-expect-error: ref is supported by all supported modals
245+
return <modal.Component {...modal.props} ref={modal.ref} key={modal.id} data-id={modal.id} />;
261246
}
262247
})}
263248
</>

0 commit comments

Comments
 (0)