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

Propagate LocalLayoutDirection into PopupLayout #562

Merged
merged 2 commits into from May 17, 2023

Conversation

m-sasha
Copy link

@m-sasha m-sasha commented May 13, 2023

Currently, we overwrite (by re-providing) a bunch of locals in ProvideCommonCompositionLocals even within a child owner. This, for example, resets a user-provided LocalLayoutDirection in popups.

Initially I had wanted to change ProvideCommonCompositionLocals to only override the locals that seem to be tied to the owner. Following a conversation with Andrey Kulikov [G], however, I decided to manually forward the local LayoutDirection to the child owner in PopupLayout, which is how Android does this.

While this solves the immediate problem with LayoutDirection, it doesn't appear to solve it for any of the other locals overridden by ProvideCommonCompositionLocals. We will need to do that when/if we discover use-cases where our overriding is undesirable.

Proposed Changes

  • In PopupLayout forward the local LayoutDirection to the child owner.
  • In SkiaBasedOwner keep the layout direction in a state variable, and when changed also propagate it to the focus owner, and root layout node.

Testing

Test: Added a unit test that makes sure LocalLayoutDirection is propagated into Popup.

Issues Fixed

Fixes: JetBrains/compose-multiplatform#3142

@m-sasha m-sasha requested review from pjBooms and igordmn May 13, 2023 08:01
@m-sasha m-sasha requested a review from igordmn May 16, 2023 18:15
@m-sasha m-sasha merged commit 344aaef into jb-main May 17, 2023
1 of 2 checks passed
@m-sasha m-sasha deleted the m-sasha/pass-only-locallayoutdirection-to-popup branch May 17, 2023 09:53
igordmn pushed a commit that referenced this pull request Jun 7, 2023
# Conflicts:
#	compose/ui/ui/src/desktopTest/kotlin/androidx/compose/ui/window/DesktopPopupTest.kt
igordmn pushed a commit that referenced this pull request Jun 23, 2023
Opted to just pass in an `EmptyCoroutineContext` to `PagingDataDiffer` instead of inlining `MainDispathcherRule`, as it's clearer to follow. The removal of `loadDispatcher` was necessary for this to pass. I didn't trace why this had to be removed, but imo it makes the tests easier to read.

Test: ./gradlew test connectedCheck
Bug: 270612487

This is an imported pull request from androidx#562.

Resolves #562
Github-Pr-Head-Sha: 1f5051a
GitOrigin-RevId: 469c543
Change-Id: Ic697668277be5ad8d7f99c244a5977127f4f96ab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants