Hi community, i have an alert dialog that uses a l...
# compose-android
m
Hi community, i have an alert dialog that uses a lazyColumn to display a list of countries. It was working perfectly till i added searchBar on it Now the issue is that when the dialog is visible i can only dismiss it by clicking outside the dialog area the back gesture doesn't dismiss it. It wasn't like this before. I tried removing the searchBar and everything went back to normal, Is their something am missing The below is the picture of my dialog code
v
Search bar internally uses
Copy code
BackHandler(enabled = active) {
    onActiveChange(false)
}
So, when you go back, you should set the search bar as not active. Something like this:
Copy code
var isActive by remember {
    mutableStateOf(false)
}

AlertDialog(onDismissRequest = { viewModel.selectStartDate(LocalDate.parse("2023-12-01")) }) {
    SearchBar(
        query = "",
        onQueryChange = {},
        onSearch = {},
        active = isActive,
        onActiveChange = { isActive = false }) {

    }
m
Thanks