diff --git a/core/src/jsMain/kotlin/dev/fritz2/core/mount.kt b/core/src/jsMain/kotlin/dev/fritz2/core/mount.kt index 049e2795b..88357684a 100644 --- a/core/src/jsMain/kotlin/dev/fritz2/core/mount.kt +++ b/core/src/jsMain/kotlin/dev/fritz2/core/mount.kt @@ -88,7 +88,7 @@ internal abstract class MountPointImpl : MountPoint, WithJob { } } -internal val MOUNT_POINT_KEY = Scope.Key("MOUNT_POINT") +val MOUNT_POINT_KEY = Scope.Key("MOUNT_POINT") /** * Allows to access the nearest [MountPoint] from any [WithScope] diff --git a/headless/src/jsMain/kotlin/dev/fritz2/headless/foundation/portalling.kt b/headless/src/jsMain/kotlin/dev/fritz2/headless/foundation/portalling.kt index f1fef8817..b2c919868 100644 --- a/headless/src/jsMain/kotlin/dev/fritz2/headless/foundation/portalling.kt +++ b/headless/src/jsMain/kotlin/dev/fritz2/headless/foundation/portalling.kt @@ -29,7 +29,7 @@ private data class PortalContainer( val remove = PortalStack.handle { list -> list.filterNot { it.portalId == portalId } } fun render(ctx: RenderContext) = - tag(ctx, classes, id, scope) { + tag(ctx, classes, id, scope + { ctx.scope[MOUNT_POINT_KEY]?.let { set(MOUNT_POINT_KEY, it) } }) { content.invoke(this) { remove.invoke() } reference?.beforeUnmount(this, null) { _, _ -> remove.invoke() } } @@ -60,7 +60,9 @@ internal object PortalRenderContext : HtmlTag("div", portalRootI attr(Aria.live, "polite") PortalStack.data.distinctUntilChangedBy { it.map { it.portalId } } - .renderEach(PortalContainer<*>::portalId, into = this) { it.render(this) } + .renderEach(PortalContainer<*>::portalId, into = this) { + it.render(this) + } MainScope().launch { delay(500)