https://kotlinlang.org logo
#compose
Title
# compose
k

Koneko Toujou

02/05/2023, 2:03 PM
hmmm there is a behavioural inconsistency o.o im on
compose.version=1.2.2
when i expand the dropdownmenu it opens ANDROID: when i tap the same button to expand the menu, it closes and does not re-expand until pressed again DESKTOP: when i tap the same button to expand the menu, it closes and re-expands even though it was not pressed again is this intended? o.o specifically
Copy code
WINDOWS:

mouse down: nothing
mouse up: OPEN (click)

mouse down: DISMISS_REQUEST
mouse up: OPEN (click)

ANDROID:

touch down: nothing
touch up: OPEN (click)

touch down: DISMISS_REQUEST
touch up: nothing
🧵 1
Copy code
Text(items[selectedIndex],modifier = Modifier.fillMaxWidth().clickable(onClick = { expanded = true; println("OPEN") }).background(Color.Cyan).height(48.dp))
        DropdownMenu(
            expanded = expanded,
            onDismissRequest = { expanded = false; println("DISMISS, CLOSE") },
            modifier = Modifier.fillMaxWidth().background(Color.Red)
        ) {
            items.forEachIndexed { index, s ->
                DropdownMenuItem(onClick = {
                    selectedIndex = index
                    expanded = false
                    println("ITEM SELECTED, CLOSE")
                }) {
                    val disabledText = if (s == disabledValue) {
                        " (Disabled)"
                    } else {
                        ""
                    }
                    Text(text = s + disabledText)
                }
            }
        }
if i use compose
1.3.0
i still get the same behaviour
could this be somehow related to a Dialog in a Window ? as on android, this behaviour matches a popup/dialog: any touch outside the popup will dismiss BUT NOT interact with anything below the popup and on windows, i think also matches in that any click outside the popup will dismiss the popup but ALSO interact with whatever is below the popup if i remember correctly
seems to be here https://github.com/JetBrains/compose-jb/issues/2586 which is exactly what i am experiencing also https://github.com/JetBrains/androidx/pull/363 which fixes it but is currently closed
with
AlertDialog
i do NOT get this behavior specifically it behaves as expected for both android and desktop
Copy code
touch down: nothing
touch up: OPEN (click)

touch down: DISMISS_REQUEST
touch up: nothing
for clarity this DOES happen for
DropdownMenu
this DOES NOT happen for
AlertDialog
3 Views