airbnb / Showkase

🔦 Showkase is an annotation-processor based Android library that helps you organize, discover, search and visualize Jetpack Compose UI elements
https://medium.com/airbnb-engineering/introducing-showkase-a-library-to-organize-discover-and-visualize-your-jetpack-compose-elements-d5c34ef01095
Apache License 2.0
2.11k stars 107 forks source link

Showkase navigation breaks when preview contains a BackHandler #267

Closed vinaygaba closed 1 year ago

vinaygaba commented 1 year ago

Fixes #247

Description of the issue

If you have BackHandler which does nothing inside @Preview it breaks navigation for Showkase browser

Snippet to reproduce:

@Composable
fun ContentScreen(
    viewModel: ContentViewModel = androidx.lifecycle.viewmodel.compose.viewModel(),
) {
    Content(onBack = viewModel::onBack)
}

@Composable
fun Content(onBack: () -> Unit) {
    BackHandler(onBack = onBack)
}

@Preview
@Composable
fun ContentPreview() {
    Content(
        onBack = {},
    )
}

If you open ContentPreview from Showkase browser, it will not be possible to navigate back

@airbnb/showkase-maintainers