diff --git a/src/lib/components/dialog/dialog-root.svelte b/src/lib/components/dialog/dialog-root.svelte index 2756221..14fa3fa 100644 --- a/src/lib/components/dialog/dialog-root.svelte +++ b/src/lib/components/dialog/dialog-root.svelte @@ -5,6 +5,7 @@ > = HtmlAtomProps & { open?: boolean; disabled?: boolean; + portal?: string | PortalBond; factory?: (props: DialogBondProps) => DialogBond; children?: Snippet<[{ dialog: DialogBond }]>; }; @@ -13,7 +14,7 @@ - - - - @@ -15,6 +15,7 @@ import { PortalsBond } from './portals'; import { RootBond } from '$svelte-atoms/core/components/root/bond.svelte'; import { port } from './utils'; + import type { PortalBond } from '.'; type Element = HtmlElementType; @@ -24,9 +25,14 @@ const portalsBond = PortalsBond.get(); const rootBond = RootBond.get(); - const portalBond = $derived( - portalsBond?.state?.get(portal!) ?? rootBond?.state?.getPortal(portal!) - ); + const portalBond = $derived.by(() => { + if (typeof portal === 'string') { + return portalsBond?.state?.get(portal!) ?? rootBond?.state?.getPortal(portal!); + } + + return portal; + }); + const targetElement = $derived(portalBond?.targetElement); function _port(node: HTMLElement) { diff --git a/src/lib/components/root/root.svelte b/src/lib/components/root/root.svelte index e401b60..5cdd0f0 100644 --- a/src/lib/components/root/root.svelte +++ b/src/lib/components/root/root.svelte @@ -114,7 +114,7 @@ {/if} - + {@render children?.()}