Skip to content

Commit 7129797

Browse files
fix(mobile): prevent chat from disappearing when scrolling (#10479)
1 parent f57d383 commit 7129797

2 files changed

Lines changed: 53 additions & 29 deletions

File tree

‎patches/@legendapp__list@3.3.5.patch‎

Lines changed: 48 additions & 24 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..24d0763aef074411eb7d17f0feb8df752a843de0 100644
244+
index b3c5a306b293f797a8b338adfca3060c0f6db22b..ddca4bcd8a5dc5863cb65e03b6cfac0047a8ead3 100644
245245
--- a/react-native.js
246246
+++ b/react-native.js
247247
@@ -717,6 +717,15 @@ function hasActiveInitialScroll(state) {
@@ -674,7 +674,19 @@ index b3c5a306b293f797a8b338adfca3060c0f6db22b..24d0763aef074411eb7d17f0feb8df75
674674
contentContainerStyle: [
675675
horizontal ? { height: "100%" } : {},
676676
contentContainerStyle,
677-
@@ -6751,7 +6950,7 @@ function createImperativeHandle(ctx, scheduleImperativeScrollCommit) {
677+
@@ -6010,7 +6209,10 @@ var ListComponent = typedMemo(function ListComponent2({
678+
],
679+
contentOffset: initialContentOffset !== void 0 ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
680+
horizontal,
681+
- maintainVisibleContentPosition: maintainVisibleContentPosition.size || maintainVisibleContentPosition.data ? { minIndexForVisible: 0 } : void 0,
682+
+ // Keep iOS anchored to ScrollAdjust even when JS position restoration is
683+
+ // disabled. Re-enabling native MVCP mid-drag can compare its stale anchor
684+
+ // with the 1e7 sentinel and scroll the entire list out of view.
685+
+ maintainVisibleContentPosition: Platform.OS === "ios" || maintainVisibleContentPosition.size || maintainVisibleContentPosition.data ? { minIndexForVisible: 0 } : void 0,
686+
onLayout,
687+
onScroll: onScroll2,
688+
ref: refScrollView,
689+
@@ -6751,7 +6953,7 @@ function createImperativeHandle(ctx, scheduleImperativeScrollCommit) {
678690
endBuffered: state.endBuffered,
679691
getAverageItemSizes: () => getAverageItemSizes(state),
680692
indexByKey: (key) => state.indexByKey.get(key),
@@ -683,15 +695,15 @@ index b3c5a306b293f797a8b338adfca3060c0f6db22b..24d0763aef074411eb7d17f0feb8df75
683695
isAtStart: peek$(ctx, "isAtStart"),
684696
isEndReached: state.isEndReached,
685697
isNearEnd: peek$(ctx, "isNearEnd"),
686-
@@ -7075,6 +7274,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
698+
@@ -7075,6 +7277,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
687699
dataVersion,
688700
drawDistance = 250,
689701
contentInsetEndAdjustment,
690702
+ contentInsetStartAdjustment,
691703
estimatedItemSize = 100,
692704
estimatedListSize,
693705
extraData,
694-
@@ -7132,10 +7332,12 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
706+
@@ -7132,10 +7335,12 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
695707
const animatedPropsInternal = props.animatedPropsInternal;
696708
const anchoredEndSpaceOwner = (_a3 = props.anchoredEndSpaceOwnerInternal) != null ? _a3 : "list";
697709
const positionComponentInternal = props.positionComponentInternal;
@@ -704,7 +716,7 @@ index b3c5a306b293f797a8b338adfca3060c0f6db22b..24d0763aef074411eb7d17f0feb8df75
704716
stickyPositionComponentInternal: _stickyPositionComponentInternal,
705717
...restProps
706718
} = rest;
707-
@@ -7200,7 +7402,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
719+
@@ -7200,7 +7405,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
708720
const combinedRef = useCombinedRef(refScroller, refScrollView);
709721
const keyExtractor = keyExtractorProp != null ? keyExtractorProp : ((_item, index) => index.toString());
710722
const stickyHeaderIndices = stickyHeaderIndicesProp;
@@ -713,23 +725,23 @@ index b3c5a306b293f797a8b338adfca3060c0f6db22b..24d0763aef074411eb7d17f0feb8df75
713725
const previousContentInsetEndAdjustmentRef = React2.useRef(contentInsetEndAdjustmentResolved);
714726
const alwaysRenderIndices = React2.useMemo(() => {
715727
const indices = getAlwaysRenderIndices(alwaysRender, dataProp, keyExtractor, anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex);
716-
@@ -7341,6 +7543,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
728+
@@ -7341,6 +7546,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
717729
contentContainerAlignItems: contentContainerStyle.alignItems,
718730
contentInset,
719731
contentInsetEndAdjustment: contentInsetEndAdjustmentResolved,
720732
+ contentInsetStartAdjustment,
721733
data: dataProp,
722734
dataKey,
723735
dataVersion,
724-
@@ -7372,6 +7575,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
736+
@@ -7372,6 +7578,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
725737
renderItem,
726738
rtl,
727739
snapToIndices,
728740
+ sizeComponentInternal,
729741
stickyHeaderIndicesArr: stickyHeaderIndices != null ? stickyHeaderIndices : [],
730742
stickyHeaderIndicesSet: React2.useMemo(() => new Set(stickyHeaderIndices != null ? stickyHeaderIndices : []), [stickyHeaderIndices == null ? void 0 : stickyHeaderIndices.join(",")]),
731743
stickyPositionComponentInternal,
732-
@@ -7423,6 +7627,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
744+
@@ -7423,6 +7630,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
733745
return void 0;
734746
}
735747
const resolvedOffset = (_a4 = initialScroll.contentOffset) != null ? _a4 : resolveInitialScrollOffset(ctx, initialScroll);
@@ -743,23 +755,23 @@ index b3c5a306b293f797a8b338adfca3060c0f6db22b..24d0763aef074411eb7d17f0feb8df75
743755
return usesBootstrapInitialScroll && ((_b2 = state.initialScrollSession) == null ? void 0 : _b2.kind) === "bootstrap" && Platform.OS === "web" ? void 0 : resolvedOffset;
744756
}, [usesBootstrapInitialScroll]);
745757
React2.useLayoutEffect(() => {
746-
@@ -7547,6 +7758,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
758+
@@ -7547,6 +7761,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
747759
[
748760
dataKey,
749761
dataVersion,
750762
+ contentInsetStartAdjustment,
751763
memoizedLastItemKeys.join(","),
752764
numColumnsProp,
753765
nextScrollAxisGap,
754-
@@ -7643,6 +7855,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
766+
@@ -7643,6 +7858,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
755767
() => ({
756768
getRenderedItem: (key) => getRenderedItem(ctx, key),
757769
onMomentumScrollEnd: (event) => {
758770
+ state.isMomentumScrolling = false;
759771
checkFinishedScrollFallback(ctx);
760772
if (state.props.onMomentumScrollEnd) {
761773
state.props.onMomentumScrollEnd(event);
762-
@@ -7651,6 +7864,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
774+
@@ -7651,6 +7867,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
763775
onScroll: (event) => onScroll(ctx, event),
764776
onScrollBeginDrag: (event) => {
765777
var _a4, _b2;
@@ -768,7 +780,7 @@ index b3c5a306b293f797a8b338adfca3060c0f6db22b..24d0763aef074411eb7d17f0feb8df75
768780
prepareReachedEdgeForNextUserScroll(ctx);
769781
(_b2 = (_a4 = state.props).onScrollBeginDrag) == null ? void 0 : _b2.call(_a4, event);
770782
},
771-
@@ -7676,11 +7891,18 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
783+
@@ -7676,11 +7894,18 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
772784
ListFooterComponent,
773785
ListFooterComponentStyle,
774786
ListHeaderComponent,
@@ -788,7 +800,7 @@ index b3c5a306b293f797a8b338adfca3060c0f6db22b..24d0763aef074411eb7d17f0feb8df75
788800
recycleItems,
789801
refreshControl: refreshControlElement ? stylePaddingTopState > 0 ? React2__namespace.cloneElement(refreshControlElement, {
790802
diff --git a/react-native.mjs b/react-native.mjs
791-
index 40e87cda8c9bc79a889e5542f29af429a24b24d4..90e0d1a9dfd07d0212aae308f547b9ff7e3ad022 100644
803+
index 40e87cda8c9bc79a889e5542f29af429a24b24d4..b8c6faf0be51cbda3e8af01f290dbe97440bc623 100644
792804
--- a/react-native.mjs
793805
+++ b/react-native.mjs
794806
@@ -696,6 +696,15 @@ function hasActiveInitialScroll(state) {
@@ -1221,7 +1233,19 @@ index 40e87cda8c9bc79a889e5542f29af429a24b24d4..90e0d1a9dfd07d0212aae308f547b9ff
12211233
contentContainerStyle: [
12221234
horizontal ? { height: "100%" } : {},
12231235
contentContainerStyle,
1224-
@@ -6730,7 +6929,7 @@ function createImperativeHandle(ctx, scheduleImperativeScrollCommit) {
1236+
@@ -5989,7 +6188,10 @@ var ListComponent = typedMemo(function ListComponent2({
1237+
],
1238+
contentOffset: initialContentOffset !== void 0 ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
1239+
horizontal,
1240+
- maintainVisibleContentPosition: maintainVisibleContentPosition.size || maintainVisibleContentPosition.data ? { minIndexForVisible: 0 } : void 0,
1241+
+ // Keep iOS anchored to ScrollAdjust even when JS position restoration is
1242+
+ // disabled. Re-enabling native MVCP mid-drag can compare its stale anchor
1243+
+ // with the 1e7 sentinel and scroll the entire list out of view.
1244+
+ maintainVisibleContentPosition: Platform.OS === "ios" || maintainVisibleContentPosition.size || maintainVisibleContentPosition.data ? { minIndexForVisible: 0 } : void 0,
1245+
onLayout,
1246+
onScroll: onScroll2,
1247+
ref: refScrollView,
1248+
@@ -6730,7 +6932,7 @@ function createImperativeHandle(ctx, scheduleImperativeScrollCommit) {
12251249
endBuffered: state.endBuffered,
12261250
getAverageItemSizes: () => getAverageItemSizes(state),
12271251
indexByKey: (key) => state.indexByKey.get(key),
@@ -1230,15 +1254,15 @@ index 40e87cda8c9bc79a889e5542f29af429a24b24d4..90e0d1a9dfd07d0212aae308f547b9ff
12301254
isAtStart: peek$(ctx, "isAtStart"),
12311255
isEndReached: state.isEndReached,
12321256
isNearEnd: peek$(ctx, "isNearEnd"),
1233-
@@ -7054,6 +7253,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1257+
@@ -7054,6 +7256,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
12341258
dataVersion,
12351259
drawDistance = 250,
12361260
contentInsetEndAdjustment,
12371261
+ contentInsetStartAdjustment,
12381262
estimatedItemSize = 100,
12391263
estimatedListSize,
12401264
extraData,
1241-
@@ -7111,10 +7311,12 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1265+
@@ -7111,10 +7314,12 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
12421266
const animatedPropsInternal = props.animatedPropsInternal;
12431267
const anchoredEndSpaceOwner = (_a3 = props.anchoredEndSpaceOwnerInternal) != null ? _a3 : "list";
12441268
const positionComponentInternal = props.positionComponentInternal;
@@ -1251,7 +1275,7 @@ index 40e87cda8c9bc79a889e5542f29af429a24b24d4..90e0d1a9dfd07d0212aae308f547b9ff
12511275
stickyPositionComponentInternal: _stickyPositionComponentInternal,
12521276
...restProps
12531277
} = rest;
1254-
@@ -7179,7 +7381,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1278+
@@ -7179,7 +7384,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
12551279
const combinedRef = useCombinedRef(refScroller, refScrollView);
12561280
const keyExtractor = keyExtractorProp != null ? keyExtractorProp : ((_item, index) => index.toString());
12571281
const stickyHeaderIndices = stickyHeaderIndicesProp;
@@ -1260,23 +1284,23 @@ index 40e87cda8c9bc79a889e5542f29af429a24b24d4..90e0d1a9dfd07d0212aae308f547b9ff
12601284
const previousContentInsetEndAdjustmentRef = useRef(contentInsetEndAdjustmentResolved);
12611285
const alwaysRenderIndices = useMemo(() => {
12621286
const indices = getAlwaysRenderIndices(alwaysRender, dataProp, keyExtractor, anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex);
1263-
@@ -7320,6 +7522,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1287+
@@ -7320,6 +7525,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
12641288
contentContainerAlignItems: contentContainerStyle.alignItems,
12651289
contentInset,
12661290
contentInsetEndAdjustment: contentInsetEndAdjustmentResolved,
12671291
+ contentInsetStartAdjustment,
12681292
data: dataProp,
12691293
dataKey,
12701294
dataVersion,
1271-
@@ -7351,6 +7554,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1295+
@@ -7351,6 +7557,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
12721296
renderItem,
12731297
rtl,
12741298
snapToIndices,
12751299
+ sizeComponentInternal,
12761300
stickyHeaderIndicesArr: stickyHeaderIndices != null ? stickyHeaderIndices : [],
12771301
stickyHeaderIndicesSet: useMemo(() => new Set(stickyHeaderIndices != null ? stickyHeaderIndices : []), [stickyHeaderIndices == null ? void 0 : stickyHeaderIndices.join(",")]),
12781302
stickyPositionComponentInternal,
1279-
@@ -7402,6 +7606,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1303+
@@ -7402,6 +7609,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
12801304
return void 0;
12811305
}
12821306
const resolvedOffset = (_a4 = initialScroll.contentOffset) != null ? _a4 : resolveInitialScrollOffset(ctx, initialScroll);
@@ -1290,23 +1314,23 @@ index 40e87cda8c9bc79a889e5542f29af429a24b24d4..90e0d1a9dfd07d0212aae308f547b9ff
12901314
return usesBootstrapInitialScroll && ((_b2 = state.initialScrollSession) == null ? void 0 : _b2.kind) === "bootstrap" && Platform.OS === "web" ? void 0 : resolvedOffset;
12911315
}, [usesBootstrapInitialScroll]);
12921316
useLayoutEffect(() => {
1293-
@@ -7526,6 +7737,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1317+
@@ -7526,6 +7740,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
12941318
[
12951319
dataKey,
12961320
dataVersion,
12971321
+ contentInsetStartAdjustment,
12981322
memoizedLastItemKeys.join(","),
12991323
numColumnsProp,
13001324
nextScrollAxisGap,
1301-
@@ -7622,6 +7834,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1325+
@@ -7622,6 +7837,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
13021326
() => ({
13031327
getRenderedItem: (key) => getRenderedItem(ctx, key),
13041328
onMomentumScrollEnd: (event) => {
13051329
+ state.isMomentumScrolling = false;
13061330
checkFinishedScrollFallback(ctx);
13071331
if (state.props.onMomentumScrollEnd) {
13081332
state.props.onMomentumScrollEnd(event);
1309-
@@ -7630,6 +7843,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1333+
@@ -7630,6 +7846,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
13101334
onScroll: (event) => onScroll(ctx, event),
13111335
onScrollBeginDrag: (event) => {
13121336
var _a4, _b2;
@@ -1315,7 +1339,7 @@ index 40e87cda8c9bc79a889e5542f29af429a24b24d4..90e0d1a9dfd07d0212aae308f547b9ff
13151339
prepareReachedEdgeForNextUserScroll(ctx);
13161340
(_b2 = (_a4 = state.props).onScrollBeginDrag) == null ? void 0 : _b2.call(_a4, event);
13171341
},
1318-
@@ -7655,11 +7870,18 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1342+
@@ -7655,11 +7873,18 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
13191343
ListFooterComponent,
13201344
ListFooterComponentStyle,
13211345
ListHeaderComponent,

‎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.

0 commit comments

Comments
 (0)