Commit 5e88e70
Move Interceptor on
## Description
#4158 introduced `ScrollViewResponderInterceptor`, which wraps all
`ScrollView` children in a single logical-responder `View`. RN's
`ScrollView.render()` resolves `stickyHeaderIndices` against
`React.Children.toArray(this.props.children)` and wraps the child at
each sticky index in `ScrollViewStickyHeader`, which counter-translates
that child against the scroll offset. With the content collapsed into
one child, index `0` is the entire content — so everything gets pinned.
Indices > 0 were a silent no-op (they pointed past the single child).
To fix this, we now move the wrapper outside of `ScrollView` and handle
keyboard dismissal manually.
Fixes #4328
## Test plan
<details>
<summary>Tested on the following code:</summary>
```tsx
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { FlatList, LegacyFlatList } from 'react-native-gesture-handler';
// Repro for #4328
// v3 FlatList with stickyHeaderIndices: scroll indicator moves, content doesn't.
// LegacyFlatList behaves correctly.
const items = Array.from({ length: 50 }, (_, i) => ({
id: i.toString(),
text: `Text content for ${i}`,
}));
export default function EmptyExample() {
const renderItem = ({ item }: { item: (typeof items)[0] }) => (
<Text style={styles.item}>{item.text}</Text>
);
return (
<View style={styles.container}>
<View style={styles.flex1}>
<FlatList
data={items}
keyExtractor={(item) => item.id}
contentContainerStyle={styles.contentContainer}
stickyHeaderHiddenOnScroll={false}
ListHeaderComponentStyle={styles.headerContainer}
stickyHeaderIndices={[0]}
ListHeaderComponent={<Text>FlatList (v3) Header</Text>}
renderItem={renderItem}
/>
</View>
<View style={styles.flex1}>
<LegacyFlatList
data={items}
keyExtractor={(item) => item.id}
contentContainerStyle={styles.contentContainer}
stickyHeaderHiddenOnScroll={false}
ListHeaderComponentStyle={styles.headerContainer}
stickyHeaderIndices={[0]}
ListHeaderComponent={<Text>LegacyFlatList Header</Text>}
renderItem={renderItem}
/>
</View>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
flex1: {
flex: 1,
},
headerContainer: {
paddingTop: 24,
paddingBottom: 12,
backgroundColor: '#f6f6f6',
},
contentContainer: {
paddingHorizontal: 24,
},
item: {
paddingVertical: 4,
},
});
```
</details>
---------
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>ScrollView, not its content (#4331)1 parent c4064f9 commit 5e88e70
3 files changed
Lines changed: 114 additions & 46 deletions
File tree
- packages/react-native-gesture-handler/src
- __tests__
- v3/components
Lines changed: 3 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
284 | 284 | | |
285 | 285 | | |
286 | 286 | | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
291 | 290 | | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | 291 | | |
296 | 292 | | |
297 | 293 | | |
| |||
Lines changed: 28 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
99 | 107 | | |
100 | | - | |
101 | | - | |
| 108 | + | |
| 109 | + | |
102 | 110 | | |
103 | 111 | | |
104 | 112 | | |
| |||
Lines changed: 83 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | | - | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
98 | | - | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
99 | 126 | | |
100 | 127 | | |
101 | 128 | | |
102 | 129 | | |
| 130 | + | |
103 | 131 | | |
104 | 132 | | |
105 | 133 | | |
| |||
115 | 143 | | |
116 | 144 | | |
117 | 145 | | |
118 | | - | |
119 | | - | |
120 | | - | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
121 | 166 | | |
122 | | - | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
123 | 182 | | |
124 | | - | |
125 | | - | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
126 | 190 | | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | 191 | | |
134 | 192 | | |
135 | 193 | | |
136 | 194 | | |
137 | | - | |
138 | | - | |
139 | 195 | | |
140 | | - | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
141 | 207 | | |
142 | 208 | | |
143 | 209 | | |
| |||
149 | 215 | | |
150 | 216 | | |
151 | 217 | | |
152 | | - | |
153 | | - | |
| |||
0 commit comments