fix(Android, FormSheet v4): Prevent FormSheet over-translation on keyboard appear in nested containers#4240
Merged
t0maboro merged 3 commits intoJul 1, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes Android FormSheet keyboard-driven translation when the sheet is presented from a container that doesn’t reach the bottom of the window (e.g., stack nested in bottom tabs) by adjusting the applied IME inset to account for the container’s bottom gap.
Changes:
- Compute an
effectiveKeyboardHeightby subtracting the “empty space below the screen container” from the raw IME bottom inset. - Cache/update the container-bottom offset at animation start and keyboard animation start (instead of assuming the container always reaches the window bottom).
- Add a new issue-test scenario intended to reproduce the nested-container FormSheet + keyboard case.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| apps/src/tests/issue-tests/TestXXXX.tsx | Adds a regression test scenario for FormSheet presented from a nested container with keyboard interaction. |
| apps/src/tests/issue-tests/index.ts | Registers the new issue test export. |
| android/src/main/java/com/swmansion/rnscreens/bottomsheet/SheetAnimationCoordinator.kt | Adjusts sheet translation logic to use container-relative effective keyboard height and caches container bottom offset. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
kligarski
approved these changes
Jul 1, 2026
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.
Description
When a
FormSheetis presented from a container that does not reach the absolute bottom of the screen (e.g., a stack nested inside bottom tabs), opening the keyboard causes the sheet to translate too far up.This happens because
SheetAnimationCoordinatorpreviously assumed the sheet's container always starts at the absolute bottom of the window. It applied the full, raw IME inset height totranslationY. As a result, a visible gap appeared between the keyboard and the bottom of the sheet.Instead of applying the raw keyboard height, we now calculate the
effectiveKeyboardHeightby subtracting the space below the sheet's container from the raw IME inset.Changes
onAnimationStartandnotifyKeyboardAnimationStart.Warning
While debugging, I noticed another related issue in
SheetDelegate. When the IME becomes visible, the delegate intercepts the insets (currently from DecorView) and explicitly zeroes out the bottom system bar (navigation bar) inset for the entire hierarchy https://github.com/software-mansion/react-native-screens/blob/4.25.2/android/src/main/java/com/swmansion/rnscreens/bottomsheet/SheetDelegate.kt#L376-L389As a result, the moment the keyboard starts sliding up, every screen receives a 0 navigation bar inset. This causes the screen's layout height to instantly increase, leading to a noticeable visual jump in its content. We should address this in a follow-up, as it seems like the FormSheet delegate shouldn't inappropriately modify or consume the navigation bar insets for the rest of the view tree.
Fixed in a followup PR: #4244
Before & after - visual documentation
before.mov
after.mov
Test plan
Adding dedicated issue test in this PR
Checklist