Commit d97f58c
Fix viewability reporting for cross-orientation nested lists (#58412)
Summary:
Pull Request resolved: #58412
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 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
Differential Revision: D1177275111 parent e15b667 commit d97f58c
5 files changed
Lines changed: 601 additions & 37 deletions
File tree
- packages
- react-native
- 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 | | |
| |||
1778 | 1778 | | |
1779 | 1779 | | |
1780 | 1780 | | |
| 1781 | + | |
1781 | 1782 | | |
1782 | 1783 | | |
1783 | 1784 | | |
| |||
1792 | 1793 | | |
1793 | 1794 | | |
1794 | 1795 | | |
| 1796 | + | |
1795 | 1797 | | |
1796 | 1798 | | |
1797 | 1799 | | |
| |||
5505 | 5507 | | |
5506 | 5508 | | |
5507 | 5509 | | |
| 5510 | + | |
5508 | 5511 | | |
5509 | 5512 | | |
5510 | 5513 | | |
| |||
| 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