[JEWEL-1298] Fix JDialogRenderer Density Issues#3475
[JEWEL-1298] Fix JDialogRenderer Density Issues#3475DanielSouzaBertoldi wants to merge 1 commit intoJetBrains:masterfrom
Conversation
|
@DanielSouzaBertoldi we can disable it if we want to, but it does check more than what ktfmt enforces IIRC |
| @@ -419,7 +421,7 @@ private fun Rectangle.withDensity(density: Float): Rectangle = | |||
| @Composable | |||
| private fun ProvideValuesFromOtherContext(context: CompositionLocalContext, content: @Composable () -> Unit) { | |||
| val existingContext = currentCompositionLocalContext | |||
| CompositionLocalProvider(context) { CompositionLocalProvider(existingContext, content) } | |||
| CompositionLocalProvider(existingContext) { CompositionLocalProvider(context, content) } | |||
There was a problem hiding this comment.
I think I found an issue connected to this change, pls correct me if I'm wrong
If I enable Custom Popup Renderer and try to open Sub menus, it just disappears and i cannot open further submenus. Video is attached.
When I revert your change, it works fine.
After some discussion with AI, he told me that "a submenu is itself another popup, opened from inside the first popup, and for that nested popup to appear correctly, the submenu code must see the current popup host component, but because of the change it sees the original parent window component." Does it make any sense? 😄
Screen.Recording.2026-04-08.at.15.26.49.mov
There was a problem hiding this comment.
Yeah, that's definitely a bug! Great catch 😄
The problem is that we were providing the local compositions of the parent window to submenus.
The fix was pretty simple, use the local compositions from the parent but override the LocalComponent to be this, pointing to the current component itself, not the parent. With this change I realized that ProvideValuesFromOtherContext is kinda redundant now so I also removed it from the code (one less abstraction layer, hell yeah). Here's the result:
Screen.Recording.2026-04-17.at.10.20.08.mov
Thank you so much for pointing this out! :)
51fdc1f to
6132539
Compare
6132539 to
fc5d5d8
Compare
fc5d5d8 to
1fdc834
Compare
|
@rock3r I disabled both |
| private fun ProvideValuesFromOtherContext(context: CompositionLocalContext, content: @Composable () -> Unit) { | ||
| val existingContext = currentCompositionLocalContext | ||
| CompositionLocalProvider(context) { CompositionLocalProvider(existingContext, content) } | ||
| } |
There was a problem hiding this comment.
This code was a bit redundant. The context parameter had its value assigned by val compositionLocalContext by rememberUpdatedState(currentCompositionLocalContext)
Then existingContext also fetched the information from currentCompositionLocalContext.
At the end of the day they were both providing the same values 😵💫
closes #3475 GitOrigin-RevId: 87572f8e99d68f1be528d93351b5aca523f89db6


(this description was generated by
jewel-pr-preparer)JDialogRendererhad two density-related bugs affecting popup positioning and content rendering when the app overridesLocalDensity.Changes
LocalDensity.currentwithdialog.density()(the actual screen scale fromgraphicsConfiguration) when converting Compose layout coordinates to AWT logical pixels inwithDensity— the screen scale factor is always the correct ratio here, independent of any app-level density override.ProvideValuesFromOtherContextto provide the ComposePanel's defaults as the outer context and the caller's composition locals as the inner context, so the caller's values (including anyLocalDensityoverride) correctly win over ComposePanel defaults instead of being silently discarded.Release notes
Bug fixes
JDialogRendererincorrectly usingLocalDensityfor AWT coordinate conversion, causing popups to appear at the wrong position or size when the app overrides the Compose density.ProvideValuesFromOtherContextswallowing caller-provided composition locals (such asLocalDensity) in favor ofComposePaneldefaults.Demo
Screen.Recording.2026-04-01.at.09.41.20.mov
Screen.Recording.2026-04-01.at.09.39.03.mov