Assigned
Status Update
Comments
ha...@nrk.no <ha...@nrk.no> #2
Not sure if this is related, but in PiP I've also had issues with ModalBottomSheetLayout being visible when it shouldn't. I've also seen this when simply rotating the device, although it is less reproducible (compared to PiP where increasing the PiP window is 100 % reproducible).
I've tried to mitigate this issue by never rendering any content when the bottom sheet isn't visible, but I'd categorize this a hacky solution and hope this gets fixed, as this seems very unnecessary to have to do.
val bottomSheetState = rememberModalBottomSheetState(initialValue = ModalBottomSheetValue.Hidden)
// This can't be based on bottomSheetState.isVisible as that will only be true after it is done animating, though it's probably
// possible to do some checks based on other values in bottomSheetState and remove this variable
var shouldShowContent by remember { mutableStateOf(bottomSheetState.isVisible) }
LaunchedEffect(bottomSheetState.isVisible) {
if (!bottomSheetState.isVisible) {
shouldShowContent = false
}
}
ModalBottomSheetLayout(
sheetState = bottomSheetState,
sheetContent = {
// sheetContent cannot be empty, otherwise it crashes
Spacer(modifier = Modifier.height(1.dp))
if (shouldShowContent) {
Something()
}
}
)
// onClick of button to show content:
onClick = {
shouldShowContent = true
scope.launch {
bottomSheetState.show()
}
}
Description
Jetpack Compose version: 1.2.0
Jetpack Compose component used: 1.2.0
Android Studio Build: Android Studio Dolphin | 2021.3.1 Patch 1 Build #AI-213.7172.25.2113.9123335, built on September 30, 2022
Kotlin version: 1.7.0
BottomSheet partly visible while keyboard is collapsing.
This issue occurs only with
com.google.android.material.bottomnavigation.BottomNavigationView on container layout. If BottomNavigationView replace by another view, issue is not occurs.
Like this:
```
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="
xmlns:app="
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/nav_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
app:labelVisibilityMode="labeled"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/bottom_nav_menu" />
//Fragment with Jetpack Compose and ModalBottomSheetLayout implementation
<androidx.fragment.app.FragmentContainerView
android:id="@+id/rootFragmentContainer"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
app:defaultNavHost="true"
app:layout_constraintBottom_toTopOf="@id/nav_view"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
```
Steps to Reproduce or Code Sample to Reproduce:
1. Tap on input field - soft keyboard is showing
2. Hide keyboard manually
3. BottomSheet will be partly visible while soft keyboard is collapsing
Stack trace (if applicable):