question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Navigating to bottom sheet and touching the sheet as it opens results in ANR

See original GitHub issue

I have an empty screen with a box and a clickable modifier.

onClick = {
 if (navController.currentDestination!!.route != "bottom_sheet") {
    navController.navigate("bottom_sheet")
...

This works fine 99% of the time unless the user presses on the bottom sheet while it’s opening. The bottom sheet cannot be dismissed which results in an ANR. It’s a “little” tricky to repro because you have to click quickly, but here’s a video of it in action.

https://user-images.githubusercontent.com/31751141/129817873-f926e2fe-ee90-4972-9cd0-38156a3b9034.mp4

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
ColtonIdlecommented, Aug 18, 2021
@Composable
fun MyHome(
    onClick: (String) -> Unit,
) {
    Box(
        modifier = Modifier
            .fillMaxSize()
            .clickable { onClick("blah") },
    ) {
    }
}
2reactions
ColtonIdlecommented, Aug 18, 2021

Repro:

@AndroidEntryPoint
class MainActivity : ComponentActivity() {

    @OptIn(ExperimentalMaterialNavigationApi::class)
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)


        setContent {
            MyTheme {

                val navController = rememberNavController()
                val bottomSheetNavigator = rememberBottomSheetNavigator()
                navController.navigatorProvider += bottomSheetNavigator
                ModalBottomSheetLayout(bottomSheetNavigator) {
                    NavHost(
                        navController = navController,
                        startDestination = Screen.MyHome.route
                    ) {
                        composable(Screen.MyHome.route) {
                            MyHome(onClick = { id ->
                                if (navController.currentDestination!!.route != "bottom_sheet") {
                                    navController.navigate("bottom_sheet")
                                }
                            })
                        }
                        bottomSheet(route = "bottom_sheet") {
                            Text("This is a cool bottom sheet!", modifier = Modifier.height(300.dp))
                        }
                    }
                }
            }
        }
    }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

android - NavigationComponent navigation within a ...
Can Android's Navigation Component be used for navigation WITHIN a BottomSheet (i.e. replacing/adding fragments within a single bottom sheet)?.
Read more >
Interact programmatically with the Navigation component
The Navigation component provides ways to programmatically create and interact with certain navigation elements.
Read more >
Introducing Navigation-Material 🎨️ | by Jossi Wolf - Medium
You can navigate to bottom sheets just like any other destination: You can navigate away from bottom sheet destinations as usual, or the...
Read more >
Modal Bottom Sheet in Android with Examples - GeeksforGeeks
Now create a bottom_sheet_layout.xml file and add the following code. Here we design the layout of our Modal Bottom sheet. It has a...
Read more >
Thrips - How to Manage Pests - UC IPM
Stippling as result of greenhouse thrips feeding. ... gently shaking foliage or flowers onto a light-colored sheet of paper, beating tray, or small...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found