fix: reconcile frozen chat keyboard padding#1493
Open
jmeistrich wants to merge 1 commit into
Open
Conversation
Contributor
📊 Package size report
|
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.
Problem
In LegendList's keyboard integration when a user sends a message we want to do at the same time:
So I am using
freezeto disable KeyboardChatScrollView's scrolling to allow our scrollToEnd to run instead. But then that makes it never report an inset less than the keyboard height, because freezing made it stop calculating keyboard height.KeyboardChatScrollViewcurrently returns early from keyboard handlers whenfreezeis true. If the keyboard closes while frozen, the hook can miss the terminal keyboard height and keep stale keyboard padding afterfreezebecomes false.In that state,
onContentInsetChangecan stop at the previous keyboard padding instead of continuing down to0, even thoughfreezeis already false.Screenshot
This is what it looks like before the fix, it reports inset shrinking while the blankSize shrinks, but to a minimum of keyboard size (288 in this case). So then there's a big bottomInset.
Solution
Keep tracking the latest keyboard height while frozen, but continue to skip layout and scroll writes during the frozen interval. When
freezetransitions from true to false, recompute the effective padding from the latest observed keyboard height.This keeps
freezescoped to applying keyboard-driven layout updates, not observing keyboard state.Notes
This intentionally reconciles padding only. It does not replay skipped scroll operations after unfreezing, because that could introduce visible jumps and is not needed for the stale inset issue.
Test plan
yarn test src/components/KeyboardChatScrollView/useChatKeyboard/__tests__/index.ios.spec.ts src/components/KeyboardChatScrollView/useChatKeyboard/__tests__/freeze.android.spec.ts --runInBandyarn lint --quiet src/components/KeyboardChatScrollView/useChatKeyboard/index.ios.ts src/components/KeyboardChatScrollView/useChatKeyboard/index.ts src/components/KeyboardChatScrollView/useChatKeyboard/__fixtures__/testUtils.ts src/components/KeyboardChatScrollView/useChatKeyboard/__tests__/index.ios.spec.ts src/components/KeyboardChatScrollView/useChatKeyboard/__tests__/freeze.android.spec.tsyarn typescript