`DropDownMenu` ignores `Density` provided from upp...
# compose
l
DropDownMenu
ignores
Density
provided from upper tree. It seems the density has been re-provided at some point inside
DropDownMenu
. Is this a compose bug or it's intended? I saw a similar discuss two years ago: https://kotlinlang.slack.com/archives/CJLTWPH7S/p1659191411566189 Following code demonstrates it:
Copy code
CompositionLocalProvider(
    LocalDensity provides customizedDensity
) {
    DropdownMenu(
    ...
    ) {
        val density = LocalDensity.current
        assertTrue(customizedDensity != density)
    }
}
s
Does it work if you re-provide it inside the content lambda?
l
It works - that’s actually my current workaround. But it’s not a for good solution as every time if I have sth which renders on a separate window (Popup, Dialog) I have to do it again.
s
Just wanted to check. I'd file a report anyway then
👍 1
a
I’m curious what your use case is for customizing the
Density
, is this for testing, a font scale feature, or a different reason?
l
Hi Alex. It's a font scale feature that user can change font scale independently within the app. My previous post: https://kotlinlang.slack.com/archives/CJLTWPH7S/p1728370240547669
👍 1
r
2 year old thread jumpscare 😂 My use case was fixing incorrect display metrics on a custom device we're developing for. It's for a kiosk-like app, so we override
LocalDensity
at the very top of the compose tree and that handles everything we care about. We ended up making a wrapper for every window-creating composable that just re-provides
LocalDensity
to the window's content.
😅 2