Repository navigation
Bring an Android bottom sheet back up when it's shown again mid-hide - #219
Merged
Merged
Conversation
If PHP shows a sheet again before its hide animation has finished, the LaunchedEffect(visible) running hide() is cancelled and the new one only sets `shown = true`. The sheet stays composed at whatever offset the hide reached, and ModalBottomSheet only plays show() when it first composes, so nothing brings it back. It stays off screen with its dialog window still on top: the keyboard stays up for the hidden field and the next tap anywhere is swallowed by the invisible scrim. The hide now marks itself as in progress. An effect that cancels it calls sheetState.show(), and the hide's finally only lets the sheet go when its own effect is still active, so a drag or M3's show() interrupting hide() still takes the sheet away as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Android, a bottom sheet that PHP shows again while it's still sliding away doesn't come back. It stays off screen, but its dialog window stays on top of the app: the keyboard stays up for the field inside it, and the next tap anywhere lands on the invisible scrim and does nothing. PHP thinks the sheet is open.
We hit it in the devnull app while working on NativePHP/dev-null-app#183. Its composer sheet closes when you post, and if the post fails straight away (no connection), it opens the sheet again with your draft. If the failure comes back inside the hide animation, about one try in three, the composer was gone and the screen stopped responding to the next tap.
Cause
BottomSheetRendererrunssheetState.hide()inLaunchedEffect(visible). Whenvisibleturns true again before the hide is done, Compose cancels that effect, and the hide stops wherever it got to. The new effect only setsshown = true. The sheet stays composed, soModalBottomSheetnever runs its first-compositionshow()again, and nothing else moves it back up.#205 doesn't cover this. Its
finally { shown = false }does run on the cancel, but the new effect setsshown = truein the same frame, so the sheet never leaves composition.Fix
hidingflag is set while the hide runs.visible = truefinds a hide was cut short, it callssheetState.show().finallyonly lets the sheet go when its own effect is still active (isActive). A drag or M3's ownshow()interruptinghide()doesn't cancel the effect, so in those cases the sheet still leaves, as fix(android): keep a closing sheet from reopening #205 intended. Being shown again does cancel the effect, and then the sheet stays for the new effect to bring back up.Testing
BottomSheetCloseTest.aSheetShownAgainWhileSlidingAwayComesBackUp: hides an open sheet, steps the clock 150 ms into the slide, shows it again, and checks it ends where it opened. Onmainit fails with the sheet's top at 514 instead of 48. With this change the wholetests/androidmodule passes (67 tests), run against mobile-airmainwith JDK 23.BottomSheetRendererTestgains a source check for the reshow, and the existing fix(android): keep a closing sheet from reopening #205 check now allows for theisActiveguard.What to watch for
visible. If a sheet'svisibleflips false and true several times quickly, each new effect either shows it or hides it from wherever it is, so it should settle on the last value. The test covers one flip.🤖 Generated with Claude Code