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

LocalLayoutDirection isn't propagated into DialogWindow #3382

Closed
mahozad opened this issue Jul 20, 2023 · 5 comments
Closed

LocalLayoutDirection isn't propagated into DialogWindow #3382

mahozad opened this issue Jul 20, 2023 · 5 comments
Assignees
Labels
bug Something isn't working desktop

Comments

@mahozad
Copy link
Contributor

mahozad commented Jul 20, 2023

Describe the bug
Creating this bug as was requested here: #3142 (comment)

LocalLayoutDirection.current returns LTR even when set to RTL outside a Dialog.

Affected platforms
Select one of the platforms below:

  • Desktop

Versions

  • Kotlin version*: 1.8.20
  • Compose Multiplatform version*: 1.4.1
  • OS version(s)* (required for Desktop and iOS issues): Windows 11
  • OS architecture (x86 or arm64): x64
  • JDK (for desktop issues): 17

Expected behavior
The provided layout direction should be seen inside the dialog composable.

@mahozad
Copy link
Contributor Author

mahozad commented Jul 30, 2023

The new common Dialog component in version 1.5.0-beta01 does not have this problem.

@m-sasha
Copy link
Contributor

m-sasha commented Jul 31, 2023

Indeed. This is because Dialog has been reimplemented on top of Popup, which already had this fixed.

@m-sasha m-sasha closed this as completed Jul 31, 2023
@m-sasha
Copy link
Contributor

m-sasha commented Jul 31, 2023

Although there's now the same issue with DialogWindow, most likely.

@m-sasha m-sasha reopened this Jul 31, 2023
@mahozad
Copy link
Contributor Author

mahozad commented Jul 31, 2023

The problem still exists with DialogWindow in version 1.5.0-beta01:

fun main() {
    application {
        var direction by remember { mutableStateOf(LayoutDirection.Rtl) }
        CompositionLocalProvider(LocalLayoutDirection provides direction) {
            DialogWindow(onCloseRequest = ::exitApplication) {
                // /* Workaround: */ CompositionLocalProvider(LocalLayoutDirection provides direction) {
                Column(modifier = Modifier.fillMaxWidth()) {
                    Text("$direction")
                    Button(onClick = { direction = if (direction == LayoutDirection.Rtl) LayoutDirection.Ltr else LayoutDirection.Rtl }) {
                        Text("Change direction")
                    }
                }
                // }
            }
        }
    }
}

@m-sasha
Copy link
Contributor

m-sasha commented Aug 31, 2023

Fixed by JetBrains/compose-multiplatform-core#777

@m-sasha m-sasha closed this as completed Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working desktop
Projects
None yet
Development

No branches or pull requests

2 participants