Is there a way to copy the local composition value...
# compose
z
Is there a way to copy the local composition values at one point in my composable then provide them in another area? I need this to be able to apply the parent composable composition locals to the launched window.
Copy code
DialogWindow(
    visible = expanded,
    onCloseRequest = { expanded = false }
) {
    // provide parent locals here
    CompositionLocalProvider {
        content()
    }
}
z
This is what
CompositionContext
is for. When you use
Dialog
or
Popup
, or even put a
ComposeView
inside a
View
inside another
ComposeView
, the new composition is wired up to the parent by passing its
CompositionContext
in. So this should happen automatically if you're using any of the built-in dialog facilities. I don't know what
DialogWindow
is, is that a desktop thing?
z
Yes, so I guess an issue should be made for it?
z
Probably? Again, I don't know where
DialogWindow
comes from
So if you're not seeing CompositionLocals come through, that's pretty weird
So yea i'd file a bug to JB
z
Alright, thanks for pointing it out
Okay so turns out I was just forgetting to wrap my components with a Surface so it had a background... So it wasn't a bug. Sorry about that, I appreciate the help regardless
👍🏻 1