Skip to content

fix: route Android sheet back through models - #416

Merged
tiensonqin merged 5 commits into
mainfrom
devin/1795684304-sheet-back-dismissal
Nov 26, 2026
Merged

tiensonqin merged 5 commits into
mainfrom
devin/1795684304-sheet-back-dismissal

Conversation

@tiensonqin

@tiensonqin tiensonqin commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Android modal sheets no longer let Material hide the native sheet before the application handles hardware Back. ModalBottomSheet now uses shouldDismissOnBackPress = false; Back emits the sheet's existing Dismiss event while the native sheet remains visible. The application model can therefore navigate inside a sheet before deciding whether the sheet should close, and the sheet disappears when the model removes it.

For sheets with a medium detent, the explicit Back handling preserves Material's hierarchy: an expanded sheet first collapses with partialExpand(), and only a later Back emits Dismiss. Outside presses and swipe dismissal keep Material's existing close behavior.

Validation

  • ./gradlew :lui:compileDebugKotlin — passed.

Link to Devin session: https://app.devin.ai/sessions/a35d6ca9bf0447df91cc820d3bd6f48f
Open in Devin Desktop: https://app.devin.ai/desktop/session/a35d6ca9bf0447df91cc820d3bd6f48f?variant=devin
Requested by: @tiensonqin


👀 3 findings for you to triage

Devin Review

@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@tiensonqin
tiensonqin merged commit 081f0cb into main Nov 26, 2026
9 checks passed
@tiensonqin
tiensonqin deleted the devin/1795684304-sheet-back-dismissal branch November 26, 2026 10:02

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 3 findings. All 3 findings are left for you to triage below.

View findings in Devin Review

Devin Review

containerColor = LocalLuiSemanticColors.current["background"] ?: MaterialTheme.colorScheme.surface,
) {
BackHandler {
if (!skipPartiallyExpanded && sheetState.currentValue == SheetValue.Expanded) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Compact medium sheets swallow Back

On a compact sheet configured with medium, BackHandler attempts to collapse even when Material created no partial anchor. The sheet does not move, and the model receives no dismissal event on the first Back press.

Learn more

The public sheet constructor sends the configured detents to the renderer. Material 3's rememberModalBottomSheetState only creates a partial anchor when the measured sheet is taller than half the available height. Without that anchor, partialExpand() changes the logical state without moving the sheet. Material's original Back handler checked hasPartiallyExpandedState and dismissed when there was no partial anchor.

Example: A sheet configured with medium,large measures 300 dp in an 800 dp viewport. Pressing Back leaves the sheet at the same height and sends no dismiss event; the model cannot close it or navigate on that press.

Recommended fix: Branch on sheetState.hasPartiallyExpandedState instead of the authored detent flag. Verify that a compact medium sheet emits dismiss on the first Back press and an expanded sheet with a real partial anchor collapses first.

Suggested change
if (!skipPartiallyExpanded && sheetState.currentValue == SheetValue.Expanded) {
if (sheetState.hasPartiallyExpandedState && sheetState.currentValue == SheetValue.Expanded) {

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

modifier = Modifier.luiChrome(node),
onDismissRequest = onDismiss,
sheetState = sheetState,
properties = ModalBottomSheetProperties(shouldDismissOnBackPress = false),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Predictive Back loses sheet feedback

BackHandler runs on commit but does not track gesture progress. Even a sheet that only collapses on Back loses Material’s gesture preview.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread docs/api-migrations.md
Comment on lines +11 to +14
unchanged. Applications already handle `sheet ~on_dismiss` by updating their
model, so no code migration is required; handlers that assumed every Back
event meant close should perform their own hierarchical back navigation before
removing the sheet.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Sheet migration lacks a model example

The on_dismiss guidance describes hierarchical navigation without a concrete example. The migration guide needs to show when a handler keeps the sheet mounted and when it removes it.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant