Change theme
Help
Press space for more information.
Show links for this issue (Shortcut: i, l)
Copy issue ID
Previous Issue (Shortcut: k)
Next Issue (Shortcut: j)
Sign in to use full features.
Vote: I am impacted
Notification menu
Refresh (Shortcut: Shift+r)
Go home (Shortcut: u)
Pending code changes (auto-populated)
View issue level access limits(Press Alt + Right arrow for more information)
Unintended behavior
View staffing
Description
Jetpack Compose version: 2.0.20
Material Library Version (M2, M3 or Both?): M3
Material Compose component used: ModalBottomSheet
Android Studio Build: #AI-241.18034.62.2412.12266719
Kotlin version: 2.0.20
The new documentation .
Unfortunately it gets overcomplicated and error-prone when a developer wants to control showing/hiding of the bottoms sheet programmatically (like second example in the documentation ).
ModalBottomSheet
API is great in simple use cases like the first example in theThe state of the bottom sheet is controlled by 2 independent variables and it's easy for developer to get them to the inconsistent state.
The problem
If developer forgets to write this code in every place where they hide the bottom sheet
and just calls
sheetState.hide()
they end up with the unresponsive screen (blocked by bottoms sheet that they don't see).Proposed solution
ModalBottomSheet
should not block the screen after it's dismissed even if it remains in composition. There should be no need forshowBottomSheet
whenModalBottomSheet
is used with hoisted state. It should be fully controlled by the state. Here is a draft showing what the second example could look like after simplifying the API.Please let me know if this is and API change you would consider. I could implement it and create a PR.