Skip to content

TextField inside DropdownMenu text pointer issue #4634

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

Closed
wadeamaral opened this issue Mar 1, 2025 · 1 comment
Closed

TextField inside DropdownMenu text pointer issue #4634

wadeamaral opened this issue Mar 1, 2025 · 1 comment
Labels

Comments

@wadeamaral
Copy link

Description:
TextFields rendered inside DropdownMenu have incorrect text pointer location

Image

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.

@leticiarossi
Copy link
Contributor

Hi, please file jetpack compose issues here instead https://issuetracker.google.com/issues/new?component=742043&template=1346811

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants