11'use client' ;
22
3- import { useIsomorphicLayoutEffect , useSyncRef } from '@ui5/webcomponents-react-base' ;
43import type { MutableRefObject } from 'react' ;
54import { createRef , useSyncExternalStore } from 'react' ;
65import { createPortal } from 'react-dom' ;
76import { getRandomId } from '../../internal/getRandomId.js' ;
8- import type { IModal } from '../../internal/ModalStore.js' ;
97import { ModalStore } from '../../internal/ModalStore.js' ;
108import type { DialogDomRef , DialogPropTypes } from '../../webComponents/Dialog/index.js' ;
119import { 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