Hi guys. How can I prevent the dragging functionality of BasicTextField. I dont want the user to be ...
d
Hi guys. How can I prevent the dragging functionality of BasicTextField. I dont want the user to be able to drag the text and make it invisible. Below a video with the functionality that I want to disable.
Copy code
@Composable
fun SearchBar(
    modifier: Modifier = Modifier,
    onSearch: (String) -> Unit = {}
) {
    var text by remember {
        mutableStateOf("")
    }

    Box(modifier = modifier) {
        BasicTextField(
            value = text,
            onValueChange = {
                text = it
                onSearch(it)
            },
            maxLines = 1,
            singleLine = true,
            textStyle = TextStyle(color = Color.Black),
            modifier = Modifier
                .fillMaxWidth()
                .shadow(5.dp, CircleShape)
                .background(Color.White, CircleShape)
        )
    }
}
That's the code of the screen above
a
you could set the
singleLine = true,
but then i think it would scroll vertically
c
What if the text is longer than the field? How would the user scroll to see it?
d
I'm limiting the entry to 10 characters
c
I would make the argument that this is an accessibility feature and you should not disable it. Some users may be using very large text, for example
z
Hm, that looks like a bug to me - the field shouldn’t scroll unless the text overflows.
d
I think the same, this looks like a bug to me