Skip to content

Propagate LocalLayoutDirection into PopupLayout - #562

Merged
Alexander Maryanovsky (m-sasha) merged 2 commits into
jb-mainfrom
m-sasha/pass-only-locallayoutdirection-to-popup
May 17, 2023
Merged

Propagate LocalLayoutDirection into PopupLayout#562
Alexander Maryanovsky (m-sasha) merged 2 commits into
jb-mainfrom
m-sasha/pass-only-locallayoutdirection-to-popup

Conversation

@m-sasha

Copy link
Copy Markdown

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
Alexander Maryanovsky (m-sasha) deleted the m-sasha/pass-only-locallayoutdirection-to-popup branch May 17, 2023 09:53
Igor Demin (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
Igor Demin (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
Zahari Zahariev (harryzz) pushed a commit to harryzz/compose-multiplatform-core that referenced this pull request Jul 28, 2026
Zahari Zahariev (harryzz) pushed a commit to harryzz/compose-multiplatform-core that referenced this pull request Jul 28, 2026
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 JetBrains#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

Development

Successfully merging this pull request may close these issues.

LocalLayoutDirection isn't propagated into Popup

2 participants