You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to implement a filterable drop down menu in Compose Web by using Material3's ExposedDropdownMenuBox.
var expand by remember { mutableStateOf(false) }
var text by remember { mutableStateOf("") }
ExposedDropdownMenuBox(
expanded = expand,
onExpandedChange = { expand =!expand },
) {
OutlinedTextField(
value = text,
label = { Text("Options") },
onValueChange = {
text = it
},
trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded = expand) },
modifier =Modifier.menuAnchor(),
)
ExposedDropdownMenu(
expanded = expand,
onDismissRequest = { expand =false },
) {
listOf("foo", "bar", "baz")
.filter { it.contains(text) }
.forEach {
DropdownMenuItem(
text = { Text(it) },
onClick = {
text = it
expand =false
}
)
}
}
}
After click the TextField, menu will auto expand.
The focus is still on the TextField, it should be able to input, but actually NOT.
If I collapse the menu, the TextField will be able to input again.
The text was updated successfully, but these errors were encountered:
It adds a parameter to menuAnchor that controls if a dropdown menu is focusable or not. It cannot be just unconditionally changed in the current version because focus is usually required there (for example for keyboard arrows navigation)
Discussed in https://github.com/JetBrains/compose-multiplatform/discussions/4693
Originally posted by JasonMing April 24, 2024
I'm trying to implement a filterable drop down menu in Compose Web by using Material3's
ExposedDropdownMenuBox
.After click the TextField, menu will auto expand.
The focus is still on the TextField, it should be able to input, but actually NOT.
If I collapse the menu, the TextField will be able to input again.
The text was updated successfully, but these errors were encountered: