Skip to content

Conversation

@m-sasha
Copy link
Member

@m-sasha m-sasha commented Jun 10, 2025

When the window is not shown, Component.getLocationOnScreen throws an exception, causing e.g.

Modifier.onGloballyPositioned { it.positionOnScreen() }

to crash.

Instead of throwing an exception, return Offset.Unspecified.

Fixes https://youtrack.jetbrains.com/issue/CMP-7380/Exception-Thrown-in-Desktop-Platform-Context-During-ModifierNode-Placed
Fixes https://youtrack.jetbrains.com/issue/CMP-8323/Material3-Modifier.badgeBounds-crashes-in-1.9.0-alpha01

Testing

Tested manually, and added a unit test.

Release Notes

Fixes - Desktop

  • Return Offset.Unspecified instead of throwing an exception in LayoutCoordinates.localToScreen and LayoutCoordinates.screenToLocal.

@m-sasha m-sasha requested a review from igordmn June 10, 2025 14:23
@m-sasha m-sasha merged commit 7597a46 into jb-main Jun 10, 2025
9 of 10 checks passed
@m-sasha m-sasha deleted the m-sasha/return-unspecified-offset-before-window-is-shown branch June 10, 2025 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants