Commit 3954161
Fix viewability reporting for cross-orientation nested lists (#58412)
Summary:
A horizontal `VirtualizedList` nested inside a vertical list could report its items through `onViewableItemsChanged` while the parent row was off screen. The existing same-orientation nesting path translates parent scroll metrics, but cross-orientation children have independent scroll axes and therefore need the visibility of their containing row as a separate signal.
Expose a semantic cell-visibility query through `VirtualizedListContext` and register cross-orientation children with the key of their containing cell. Parents evaluate those cells after scroll and layout changes, but invoke children only when the ancestor suppression state transitions. Known data rows without layout metrics fail closed, eliminating transient mount reports, while unsupported structural cells preserve the previous behavior.
Explicit suppression now clears previously published viewability tokens even when current cell metrics are unavailable. It also invalidates stale `minimumViewTime` work. Suppression propagates through deeper cross-orientation nesting, and parent registration is reconciled when orientation or context changes so unmount always cleans up the exact collection that was registered.
The new behavior is gated behind the `fixCrossOrientationNestedListViewability` JS feature flag, which defaults to off. While it is off, parents do not expose the cell-visibility query, so cross-orientation children are never registered or suppressed and nested lists behave as before. Independently of the flag, `ViewabilityHelper` now invalidates a pending `minimumViewTime` callback when an update returns early.
The implementation is kept in sync across the main, Windows, and macOS variants. The generated public API snapshot is updated accordingly.
Fixes #57797
Fixes #57778
Changelog:
[General][Fixed] - Do not report viewable items for a cross-orientation nested list while its parent row is off screen
Reviewed By: Abbondanzo
Differential Revision: D1177275111 parent 6421738 commit 3954161
9 files changed
Lines changed: 1530 additions & 38 deletions
File tree
- packages
- react-native
- scripts/featureflags
- src/private/featureflags
- virtualized-lists/Lists
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
1771 | 1771 | | |
1772 | 1772 | | |
1773 | 1773 | | |
| 1774 | + | |
1774 | 1775 | | |
1775 | 1776 | | |
1776 | 1777 | | |
| |||
1785 | 1786 | | |
1786 | 1787 | | |
1787 | 1788 | | |
| 1789 | + | |
1788 | 1790 | | |
1789 | 1791 | | |
1790 | 1792 | | |
| |||
5503 | 5505 | | |
5504 | 5506 | | |
5505 | 5507 | | |
| 5508 | + | |
5506 | 5509 | | |
5507 | 5510 | | |
5508 | 5511 | | |
| |||
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1091 | 1091 | | |
1092 | 1092 | | |
1093 | 1093 | | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
1094 | 1105 | | |
1095 | 1106 | | |
1096 | 1107 | | |
| |||
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| |||
185 | 186 | | |
186 | 187 | | |
187 | 188 | | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
188 | 194 | | |
189 | 195 | | |
190 | 196 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
86 | 88 | | |
87 | 89 | | |
88 | 90 | | |
| |||
96 | 98 | | |
97 | 99 | | |
98 | 100 | | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | 101 | | |
103 | 102 | | |
104 | 103 | | |
| |||
197 | 196 | | |
198 | 197 | | |
199 | 198 | | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
200 | 202 | | |
| 203 | + | |
201 | 204 | | |
202 | 205 | | |
203 | | - | |
204 | | - | |
205 | | - | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
206 | 209 | | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
207 | 222 | | |
208 | 223 | | |
209 | 224 | | |
210 | | - | |
| 225 | + | |
211 | 226 | | |
212 | 227 | | |
213 | 228 | | |
| |||
218 | 233 | | |
219 | 234 | | |
220 | 235 | | |
221 | | - | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
222 | 240 | | |
223 | 241 | | |
224 | 242 | | |
225 | 243 | | |
226 | 244 | | |
227 | 245 | | |
| 246 | + | |
228 | 247 | | |
| 248 | + | |
229 | 249 | | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | 250 | | |
234 | | - | |
235 | | - | |
| 251 | + | |
236 | 252 | | |
237 | 253 | | |
| 254 | + | |
238 | 255 | | |
239 | 256 | | |
240 | 257 | | |
241 | 258 | | |
242 | 259 | | |
243 | 260 | | |
244 | 261 | | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | 262 | | |
249 | 263 | | |
| 264 | + | |
250 | 265 | | |
251 | 266 | | |
252 | 267 | | |
| |||
261 | 276 | | |
262 | 277 | | |
263 | 278 | | |
| 279 | + | |
| 280 | + | |
264 | 281 | | |
265 | 282 | | |
266 | 283 | | |
| |||
0 commit comments