Skip to content

Animate ModalBottomSheet hide on composition removal#880

Open
g000sha256 wants to merge 1 commit into
androidx:androidx-mainfrom
g000sha256:g000sha256/modal-bottom-sheet-animate-on-removal
Open

Animate ModalBottomSheet hide on composition removal#880
g000sha256 wants to merge 1 commit into
androidx:androidx-mainfrom
g000sha256:g000sha256/modal-bottom-sheet-animate-on-removal

Conversation

@g000sha256

Copy link
Copy Markdown

Proposed Changes

When ModalBottomSheet is removed from the composition hierarchy, its underlying dialog window is dismissed immediately, and the sheet disappears abruptly, without playing the exit animation.

This is particularly noticeable with Navigation 3, where ModalBottomSheet is hosted as a separate scene and may be removed by navigation stack changes rather than by user dismissal. In this case, the sheet vanishes instantly rather than sliding out smoothly.

This change defers dismissal of the dialog window until the sheet has finished animating to Hidden. Internally, ModalBottomSheetDialog gains a new animateToHidden suspend hook that ModalBottomSheet wires to sheetState.hide(). On composition removal, the dialog waits for a one-shot signal, runs the exit animation inside the dialog's own composition, and only then dismisses the window and disposes the composition. The closing behavior now matches that of an explicit onDismissRequest.

@g000sha256 g000sha256 force-pushed the g000sha256/modal-bottom-sheet-animate-on-removal branch from 4b29b4f to 6b9fade Compare May 8, 2026 17:43
@g000sha256 g000sha256 force-pushed the g000sha256/modal-bottom-sheet-animate-on-removal branch from 6b9fade to 9517a01 Compare May 8, 2026 17:46
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