JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
16.26k stars 1.18k forks source link

Misaligned DropdownMenu #139

Closed kirill-grouchnikov closed 3 years ago

kirill-grouchnikov commented 3 years ago

Taking the core Compose sample from https://android.googlesource.com/platform/frameworks/support/+/refs/heads/androidx-master-dev/compose/material/material/samples/src/main/java/androidx/compose/material/samples/MenuSamples.kt and trying it on desktop (macOS + build129):

fun main() {
    Window(
        title = "Drop Demo",
        size = IntSize(500, 600)
    ) {
        var expanded by remember { mutableStateOf(false) }

        val iconButton = @Composable {
            IconButton(modifier = Modifier.background(Color.Green),
                onClick = { expanded = true }) {
                Icon(Icons.Default.MoreVert)
            }
        }
        DropdownMenu(
            expanded = expanded,
            onDismissRequest = { expanded = false },
            toggle = iconButton,
            toggleModifier = Modifier.fillMaxSize().wrapContentSize(Alignment.TopStart)
        ) {
            DropdownMenuItem(onClick = { /* Handle refresh! */ }) {
                Text("Refresh")
            }
            DropdownMenuItem(onClick = { /* Handle settings! */ }) {
                Text("Settings")
            }
            Divider()
            DropdownMenuItem(onClick = { /* Handle send feedback! */ }) {
                Text("Send Feedback")
            }
        }
    }
}

When the green button with the vertical dots is clicked, the menu is displayed all the way in the bottom right corner of the window:

dropdown-desktop
kirill-grouchnikov commented 3 years ago

Relevant code seems to be in the first (and only so far) pass of https://android-review.googlesource.com/c/platform/frameworks/support/+/1502053/2/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/window/DesktopPopup.kt

olonho commented 3 years ago

Yes, this issue is known and will be fixed with https://android-review.googlesource.com/c/platform/frameworks/support/+/1507759

olonho commented 3 years ago

Shall be fixed with 0.2.0-build131 image

okushnikov commented 4 months ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.