Closed
Description
Description:
TextFields rendered inside DropdownMenu have incorrect text pointer location

Expected behavior: Screenshots and/or description of expected behavior
Source code:
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun ComboBox(
options: List<String>,
selectedOption: String,
onOptionSelected: (String) -> Unit
) {
var expanded by remember { mutableStateOf(false) }
var valueText by remember { mutableStateOf(options[0]) }
var searchText by remember { mutableStateOf(options[0]) }
ExposedDropdownMenuBox(
expanded = expanded,
onExpandedChange = { expanded = it }
) {
TextField(
modifier = Modifier
.menuAnchor(MenuAnchorType.PrimaryNotEditable),
value = valueText,
onValueChange = { valueText = it },
readOnly = true,
singleLine = true
)
ExposedDropdownMenu(
expanded = expanded,
onDismissRequest = { expanded = false }
) {
TextField(
value = searchText,
onValueChange = { searchText = it }
)
options.forEach { option ->
DropdownMenuItem(
text = {
Text(option)
},
onClick = {
valueText = option
expanded = false
}
)
}
}
}
}
Minimal sample app repro: Please consider attaching a minimal sample app that reproduces the issue. This will help narrow down the conditions required for reproducing the issue, and it will speed up the bug fix process. You may attach a zip file of the sample app or link to a GitHub repo that contains the sample app.
Android API version:
34
Material Library version:
1.3.1
Device:
All devices tested
To help us triage faster, please check to make sure you are using the latest version of the library.
We also happily accept pull requests.