Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent a few unnecessary recompositions in Popup and DesktopMenu. #1225

Merged
merged 1 commit into from
Apr 2, 2024

Conversation

m-sasha
Copy link
Member

@m-sasha m-sasha commented Mar 27, 2024

Proposed Changes

  • Prevent a few unnecessary recompositions by accessing remembered values in lambdas.
  • Switch DesktopMenuTests to runComposeUiTest.

@m-sasha m-sasha requested a review from MatkovIvan March 27, 2024 11:53
@m-sasha
Copy link
Member Author

m-sasha commented Apr 2, 2024

This isn't a must-have PR.

I started working on it when I noticed that focusManager and inputModeManager in OpenDropdownMenu weren't remembered, but then I realized that I couldn't make a bug out of that because I don't think it's possible for OpenDropdownMenu to be recomposed without the Popup content also recomposing.

So I decided to pivot to slightly improving the code instead :-)

@m-sasha m-sasha merged commit 277215f into jb-main Apr 2, 2024
6 checks passed
@m-sasha m-sasha deleted the m-sasha/prevent-unnecessary-popup-recompositions branch April 2, 2024 18:56
@@ -392,11 +390,15 @@ fun Popup(
onKeyEvent: ((KeyEvent) -> Boolean)? = null,
content: @Composable () -> Unit
) {
val currentOnDismissRequest by rememberUpdatedState(onDismissRequest)
val currentOnKeyEvent by rememberUpdatedState(onKeyEvent)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to do the same for dialog then

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.

3 participants