Repository navigation
fix: KeyboardChatScrollView + new reanimated compatibility - #1629
Merged
Merged
Conversation
Contributor
📊 Package size report
|
This was referenced Sep 7, 2026
kirillzyusko
marked this pull request as ready for review
September 8, 2026 11:26
Contributor
|
LGTM |
chrisnojima
added a commit
to keybase/client
that referenced
this pull request
Sep 8, 2026
Replaces our one-line `result.contentOffset = undefined` patch with the upstream fix, kirillzyusko/react-native-keyboard-controller#1629, merged to main but not in a release yet (1.22.4 is still latest), so it stays a patch. Both fixes turn on the same property: Reanimated 4.6 classifies a settled animated value as a prop or a style using only the keys present in the FIRST animatedProps evaluation, and a key that shows up later is filed as a style, which switches on the settled-props render path and re-renders a stale contentInset of 0 over the real props, so UIKit clamps contentOffset to 0. Ours declared the key while still swallowing the value. Upstream stops swallowing entirely: contentOffsetY is seeded from the ScrollView's own contentOffset.y (threaded through useChatKeyboard and useScrollState), so the first evaluation can emit a real contentOffset instead of clobbering the list's initial scroll position with {x:0,y:0} — which was the reason the swallow existed. prevContentOffsetY starts null, so the key is always in the first evaluation. Upstream's version is the better one: it also carries contentOffset.x, and fixes the initial-offset case for direct ScrollViewWithBottomPadding users rather than only for us. Patch regenerated with --include 'src/'; its +/- lines are identical to the upstream PR.
chrisnojima
added a commit
to keybase/client
that referenced
this pull request
Sep 8, 2026
…ntOffset fix (#29599) * chore(deps): routine bumps expo 57.0.21, react-native-worklets 0.12.2, babel-preset-expo 57.0.11, eslint 10.10.0, typescript-eslint 8.70.0, @playwright/test 1.63.0, wdio/webdriverio 9.31.7, @rolldown/plugin-babel 0.2.4; protocol @types/node 26.5.0; react-native-kb react-native-builder-bob 0.43.1. Resolutions: drop the now-redundant **/deepmerge-ts entry (^8.0.0 resolves to 8.0.2 on its own) and add **/mocha/diff so mocha's diff@^7.0.0 picks up 8.0.4 (GHSA-73rr-hh4g-fpgx). * docs(skill): note **/mocha/diff as a known-needed resolution * fix(chat): take upstream's keyboard-controller fix instead of our own Replaces our one-line `result.contentOffset = undefined` patch with the upstream fix, kirillzyusko/react-native-keyboard-controller#1629, merged to main but not in a release yet (1.22.4 is still latest), so it stays a patch. Both fixes turn on the same property: Reanimated 4.6 classifies a settled animated value as a prop or a style using only the keys present in the FIRST animatedProps evaluation, and a key that shows up later is filed as a style, which switches on the settled-props render path and re-renders a stale contentInset of 0 over the real props, so UIKit clamps contentOffset to 0. Ours declared the key while still swallowing the value. Upstream stops swallowing entirely: contentOffsetY is seeded from the ScrollView's own contentOffset.y (threaded through useChatKeyboard and useScrollState), so the first evaluation can emit a real contentOffset instead of clobbering the list's initial scroll position with {x:0,y:0} — which was the reason the swallow existed. prevContentOffsetY starts null, so the key is always in the first evaluation. Upstream's version is the better one: it also carries contentOffset.x, and fixes the initial-offset case for direct ScrollViewWithBottomPadding users rather than only for us. Patch regenerated with --include 'src/'; its +/- lines are identical to the upstream PR.
ahalekelly
added a commit
to ahalekelly/t3code
that referenced
this pull request
Sep 27, 2026
Reanimated 4.6 files settled animated-prop keys as style unless they appear in the first useAnimatedProps evaluation, so cleanup reset the keyboard integration's late contentOffset and active conversations lost their scroll position (software-mansion/react-native-reanimated#10560). Keyboard-controller 1.22.5 emits contentOffset in the first evaluation (kirillzyusko/react-native-keyboard-controller#1629), so the Reanimated patch is no longer needed. The keyboard-controller patch is rebased onto 1.22.5. Its onInteractive handler now also sets 1.22.5's interactive-dismissal marker, and the lib builds import the reanimated hooks through the package's own wrapper. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
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
Fix iOS
KeyboardChatScrollViewscroll jumps with Reanimated 4.6 while preserving initial and subsequent JScontentOffset.yvalues.Initialize the existing offset shared value and scroll state from
contentOffset.y, include the initializedcontentOffsetin the firstuseAnimatedPropsevaluation, and synchronize later JS changes into the same shared value withuseEffect.The
prevContentOffsetYguard remains: inset-only updates must not replay a previous scroll command.💡 Motivation and Context
Closes #1623 #1609
#1496 fixed an initial-position regression by skipping the first animated
contentOffsetevaluation. Before that fix, our shared value started at0, so the first animated props overwrote a JS offset such as{ x: 0, y: 500 }with{ x: 0, y: 0 }.The upstream history explains why this became a problem now. Reanimated #8529 introduced synchronization of settled animation values back to React. Before Reanimated #10140, that synchronization spread the entire settled bag into both props and style, so a late
contentOffsetstill reached the native component as a prop. Reanimated #10140 correctly separated the two to prevent animated styles from leaking into unrelated component props. It exposed our dependency on that previous behavior.Skipping that prop now causes a problem with Reanimated 4.6's settled-animation synchronization. Reanimated identifies animated props by the keys present in their initial evaluation. A
contentOffsetintroduced only during keyboard movement is absent from those keys, so it is synchronized as a style instead of a top-level prop. Once Reanimated releases the settled entry from its props registry, a subsequent React commit can reset the native offset. Typing into a controlled input exposes this as the list dropping behind the keyboard (#1623).The replacement addresses both cases:
y = 500seeds both the animated target and the tracked scroll position. The first animated props containcontentOffset: { x: 0, y: 500 }, so they preserve the requested position and identify the prop to Reanimated.y = 700updates the existing shared value throughuseEffect; the animated props then apply700.📢 Changelog
JS
KeyboardChatScrollView's animated offset and scroll state from the suppliedcontentOffset.y.contentOffset.yupdates with the animated offset.iOS
🤔 How Has This Been Tested?
Recordings use
FabricExample, a dedicated iPhone 17 simulator running iOS 26.2, and Metro 8084. Native build/dependencies come fromfeat/rn-0.87(React Native 0.87.1, React 19.2.3, Reanimated 4.6.0, Worklets 0.12.1). After the two baseline recordings, the checkout is switched tofeat/kcsv-new-rea-compatibilityfor the fixed recordings, retaining the same native build and installed dependencies.The native app was built successfully with Xcode. The same demo source and Metro configuration were retained for all recordings; the library changes are the five files in this PR (
869a0c4). No changes to Reanimated were introduced for the comparison.Runtime flags:
FORCE_REACT_RENDER_FOR_SETTLED_ANIMATIONS=true,USE_COMMIT_HOOK_ONLY_FOR_REACT_COMMITS=true, andDISABLE_COMMIT_PAUSING_MECHANISM=false. The reproduction branch already includes a native patch makingpauseReanimatedCommits()a no-op; that patch stayed identical in every recording. These are results for that reproduction environment.Temporary logging captured native
onScrollevents and Reanimated's initial animated props, settled state, and outgoing React props. The loggers only recorded values; they did not update React state or scroll the list.y=500y=0; the video starts at row 1 instead of row 9.y=500; row 9 is visible immediately.yto700produces a native scroll event at700andsettledProps.contentOffset.y=700.Testychanges from-317to0on typing.contentInset.topstays318; the latest messages fall behind the keyboard.-317, with no reset event; the latest messages remain above the keyboard during typing.contentOffsetis absent from the initial keys and ends up insettledStyle.contentOffset;settledPropsand outgoing React props retain{ x: 0, y: -317 }.Code used for #1496
A focused temporary
FabricExample/src/PR1629OffsetExample.tsxscreen was used. The first button mounts the list withy = 500; the second changes the JS prop to700. Each row is 60 points high, making the starting position visible in the recording. The full screen is included below so the initial-offset and later-update checks can be repeated.PR1629OffsetExample.tsx
Code used for #1623
Used the existing Chat Kit /
KeyboardChatScrollViewPlaygroundexample:FabricExample/src/screens/Examples/KeyboardChatScrollView/index.tsxFabricExample/src/screens/Examples/KeyboardChatScrollView/VirtualizedListScrollView.tsxdata.ts,store.ts, andconfig.tsxin that directory.Open Chat Kit in its default mode first. After it mounts, select Use Flat List, enable Toggle inverted, and leave
keyboardLiftBehavior="always". For the recordings these same existing store setters were called through the debugger after mounting:The example already uses a controlled
TextInput(value={text},onChangeText={onInput}→setText(value)) and aFlatListwhoserenderScrollComponentrendersKeyboardChatScrollView. The latter receivesinverted,contentInsetAdjustmentBehavior="never", andoffset={bottom - MARGIN}. On this simulator the configured offset is34 - 16 = 18. The recorded keyboard-adjusted position isy=-317, and the inverted list's effective top inset is318.Focus the input, wait for the animation and settled synchronization, then type
Test. Both chat videos begin with the keyboard already open and settled so the change caused by typing is easy to compare. Only anonScrolllogger was added to the existing scroll wrapper, forwarding the event to the original callback.📸 Screenshots (if appropriate):
Before
1-before1496.mp4
2-before1623.mp4
y=500, but the first animated props overwrite it with0: row 1 appears.Testresetsy=-317to0. The latest messages drop behind the keyboard while the inset stays318.After
3-after1496.mp4
4-after1623.mp4
y=500(row 9). Updating the JS prop to700scrolls to the requested position.-317.📝 Checklist