Skip to content

Commit 4a0ab3e

Browse files
fix(mobile): preserve explicit initial message targets
1 parent b5e6afb commit 4a0ab3e

3 files changed

Lines changed: 19 additions & 9 deletions

File tree

‎patches/@[email protected]‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ index ce1fe00001c9e5aee6c6ea8bb2d4757d4586d002..3ccf6f16067152dfcb0c143371e2ec6a
241241
* Number of columns to render items in.
242242
* @default 1
243243
diff --git a/react-native.js b/react-native.js
244-
index b3c5a306b293f797a8b338adfca3060c0f6db22b..c239dae7390aead3968863fc0d5a4de165521bc6 100644
244+
index b3c5a306b293f797a8b338adfca3060c0f6db22b..5ac6bbe8fe40bf252fefa6b885c2196d0677d75f 100644
245245
--- a/react-native.js
246246
+++ b/react-native.js
247247
@@ -717,6 +717,15 @@ function hasActiveInitialScroll(state) {
@@ -277,7 +277,7 @@ index b3c5a306b293f797a8b338adfca3060c0f6db22b..c239dae7390aead3968863fc0d5a4de1
277277
+ // Native contentOffset can seed an end target without dispatchInitialScroll.
278278
+ // Both overflow completion paths must wait for the native end landing.
279279
+ // Underflow needs no scroll: preserve UIKit's untouched resting position.
280-
+ if (state.didContainersLayout && state.didFinishInitialScroll && state.initialScroll && state.initialScroll.viewPosition === 1 && state.props.data.length > 0) {
280+
+ if (state.didContainersLayout && state.didFinishInitialScroll && state.initialScroll && state.initialScroll.viewPosition === 1 && state.initialScroll.index === state.props.data.length - 1 && state.props.data.length > 0) {
281281
+ const insetStartAdjustment = getContentInsetStartAdjustment(ctx);
282282
+ if (insetStartAdjustment > 0 && getContentSize(ctx) > state.scrollLength - insetStartAdjustment + 1) {
283283
+ startInsetEndSettleWatchdog(ctx);
@@ -809,7 +809,7 @@ index b3c5a306b293f797a8b338adfca3060c0f6db22b..c239dae7390aead3968863fc0d5a4de1
809809
recycleItems,
810810
refreshControl: refreshControlElement ? stylePaddingTopState > 0 ? React2__namespace.cloneElement(refreshControlElement, {
811811
diff --git a/react-native.mjs b/react-native.mjs
812-
index 40e87cda8c9bc79a889e5542f29af429a24b24d4..c5c131969e03afab6859c04022b8620cc43e7e5e 100644
812+
index 40e87cda8c9bc79a889e5542f29af429a24b24d4..93aac741d2cf77ce35996362439108176f19da7a 100644
813813
--- a/react-native.mjs
814814
+++ b/react-native.mjs
815815
@@ -696,6 +696,15 @@ function hasActiveInitialScroll(state) {
@@ -845,7 +845,7 @@ index 40e87cda8c9bc79a889e5542f29af429a24b24d4..c5c131969e03afab6859c04022b8620c
845845
+ // Native contentOffset can seed an end target without dispatchInitialScroll.
846846
+ // Both overflow completion paths must wait for the native end landing.
847847
+ // Underflow needs no scroll: preserve UIKit's untouched resting position.
848-
+ if (state.didContainersLayout && state.didFinishInitialScroll && state.initialScroll && state.initialScroll.viewPosition === 1 && state.props.data.length > 0) {
848+
+ if (state.didContainersLayout && state.didFinishInitialScroll && state.initialScroll && state.initialScroll.viewPosition === 1 && state.initialScroll.index === state.props.data.length - 1 && state.props.data.length > 0) {
849849
+ const insetStartAdjustment = getContentInsetStartAdjustment(ctx);
850850
+ if (insetStartAdjustment > 0 && getContentSize(ctx) > state.scrollLength - insetStartAdjustment + 1) {
851851
+ startInsetEndSettleWatchdog(ctx);

‎pnpm-lock.yaml‎

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎scripts/legend-list-initial-reveal.test.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,16 @@ for (const bundle of ["react-native.js", "react-native.mjs"]) {
101101
expect(list.ready()).toBe(true);
102102
});
103103

104+
it("preserves an initial index before the last item", () => {
105+
const list = createList(bundle);
106+
list.state.props.data = ["requested message", "later message"];
107+
list.state.scroll = 200;
108+
list.complete();
109+
list.advance(8);
110+
expect(list.ready()).toBe(true);
111+
expect(list.scrollTo).not.toHaveBeenCalled();
112+
});
113+
104114
it("does not count an in-flight scroll as stability", () => {
105115
const list = createList(bundle);
106116
list.state.lastNativeScroll = 400;

0 commit comments

Comments
 (0)