fix(Android): fix formSheet sliding from top when it contains input with autofocus #2909
+121
−1
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
On API 36, formSheet that contains input with autoFocus would sometimes slide from the top.
Even though
react-native-screens
usedcom.google.android.material:material:1.6.1
,InsetsAnimationCallback
(which is not present in1.6.1
) is called (it probably comes fromcom.google.android.material:material:1.12.0
dependency inreact-native-edge-to-edge
). This callback interferes with our formSheet entering/closing animations:InsetsAnimationCallback
'sonPrepare
andonStart
are usually incorrect. This has become a significant issue since API 36: for some reason, animation created inScreenStackFragment
'sonCreateAnimator
is sometimes incorrecly accounted for in calculatingstartTranslationY
. The value becomes negative which means that the formSheet slides from the top.InsetsAnimationCallback
and formSheet animations usesetTranslationY
and they are overwriting each other's changes.InsetsAnimationCallback
'sonProgress
is called just after animation'ssetTranslationY
so it takes precedence.We decided to replace the window insets animation callback which is set in
BottomSheetBehavior
'sonLayoutChild
with our own implementation. Currently it is empty in order to bring back previous behavior.FormSheet that contains input with autoFocus still does not behave as intented - only rarely it gets expanded with the keyboard. This seems to be a timing issue and needs more investigation. It might be necessary to implement logic in new window insets animation callback.
Fixes #2895.
Changes
com.google.android.material:material
version to1.12.0
BottomSheetBehavior
'sInsetsAnimationCallback
with empty implementationTest2895
Test code and steps to reproduce
Open
Test2895
screen in the example app and open the formSheet.Checklist