Commit dd6325b
TalkBack support for ScrollView accessibility announcements (list and grid) (facebook#33180)
Summary:
This issue fixes [30977][17] . The Pull Request was previously published by [intergalacticspacehighway][13] with [31666][19].
The solution consists of:
1. Adding Javascript logic in the [FlatList][14], SectionList, VirtualizedList components to provide accessibility information (row and column position) for each cell in the method [renderItem][20] as a fourth parameter [accessibilityCollectionItem][21]. The information is saved on the native side in the AccessibilityNodeInfo and announced by TalkBack when changing row, column, or page ([video example][12]). The prop accessibilityCollectionItem is available in the View component which wraps each FlatList cell.
2. Adding Java logic in [ReactScrollView.java][16] and HorizontalScrollView to announce pages with TalkBack when scrolling up/down. The missing AOSP logic in [ScrollView.java][10] (see also the [GridView][11] example) is responsible for announcing Page Scrolling with TalkBack.
Relevant Links:
x [Additional notes on this PR][18]
x [discussion on the additional container View around each FlatList cell][22]
x [commit adding prop getCellsInItemCount to VirtualizedList][23]
## Changelog
[Android] [Added] - Accessibility announcement for list and grid in FlatList
Pull Request resolved: facebook#33180
Test Plan:
[1]. TalkBack announces pages and cells with Horizontal Flatlist in the Paper Renderer ([link][1])
[2]. TalkBack announces pages and cells with Vertical Flatlist in the Paper Renderer ([link][2])
[3]. `FlatList numColumns={undefined}` Should not trigger Runtime Error NoSuchKey exception columnCount when enabling TalkBack. ([link][3])
[4]. TalkBack announces pages and cells with Nested Horizontal Flatlist in the rn-tester app ([link][4])
[1]: fabOnReact/react-native-notes#6 (comment)
[2]: fabOnReact/react-native-notes#6 (comment)
[3]: fabOnReact/react-native-notes#6 (comment)
[4]: fabOnReact/react-native-notes#6 (comment)
[10]:https://github.com/aosp-mirror/platform_frameworks_base/blob/1ac46f932ef88a8f96d652580d8105e361ffc842/core/java/android/widget/AdapterView.java#L1027-L1029 "GridView.java method responsible for calling setFromIndex and setToIndex"
[11]:fabOnReact/react-native-notes#6 (comment) "test case on Android GridView"
[12]:fabOnReact/react-native-notes#6 (comment) "TalkBack announces pages and cells with Horizontal Flatlist in the Paper Renderer"
[13]:https://github.com/intergalacticspacehighway "github intergalacticspacehighway"
[14]:https://github.com/fabriziobertoglio1987/react-native/blob/80acf523a4410adac8005d5c9472fb87f78e12ee/Libraries/Lists/FlatList.js#L617-L636 "FlatList accessibilityCollectionItem"
[16]:https://github.com/fabriziobertoglio1987/react-native/blob/5706bd7d3ee35dca48f85322a2bdcaec0bce2c85/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java#L183-L184 "logic added to ReactScrollView.java"
[17]: facebook#30977
[18]: fabOnReact/react-native-notes#6
[19]: facebook#31666
[20]: https://reactnative.dev/docs/next/flatlist#required-renderitem "FlatList renderItem documentation"
[21]: 7514735 "commit that introduces fourth param accessibilityCollectionItem in callback renderItem"
[22]: facebook#33180 (comment) "discussion on the additional container View around each FlatList cell"
[23]: d50fd1a "commit adding prop getCellsInItemCount to VirtualizedList"
Reviewed By: kacieb
Differential Revision: D34518929
Pulled By: blavalla
fbshipit-source-id: 410a05263a56162bf505a4cad957b24005ed65ed1 parent 47d742a commit dd6325b
File tree
24 files changed
+1055
-51
lines changed- Libraries
- Components/View
- Lists
- __tests__/__snapshots__
- ReactAndroid/src/main
- java/com/facebook/react
- uimanager
- views/scroll
- res/views/uimanager/values
- packages/rn-tester/js
- examples
- FlatList
- SectionList
- utils
24 files changed
+1055
-51
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
464 | 464 | | |
465 | 465 | | |
466 | 466 | | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
467 | 484 | | |
468 | 485 | | |
469 | 486 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
624 | 624 | | |
625 | 625 | | |
626 | 626 | | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
627 | 633 | | |
628 | 634 | | |
629 | | - | |
| 635 | + | |
630 | 636 | | |
| 637 | + | |
631 | 638 | | |
632 | 639 | | |
633 | 640 | | |
| |||
658 | 665 | | |
659 | 666 | | |
660 | 667 | | |
| 668 | + | |
661 | 669 | | |
662 | 670 | | |
663 | 671 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
55 | 65 | | |
56 | 66 | | |
57 | 67 | | |
58 | 68 | | |
| 69 | + | |
59 | 70 | | |
60 | 71 | | |
61 | 72 | | |
| |||
84 | 95 | | |
85 | 96 | | |
86 | 97 | | |
87 | | - | |
| 98 | + | |
88 | 99 | | |
89 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
90 | 111 | | |
91 | 112 | | |
92 | 113 | | |
| |||
306 | 327 | | |
307 | 328 | | |
308 | 329 | | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
309 | 334 | | |
310 | 335 | | |
311 | 336 | | |
| |||
1242 | 1267 | | |
1243 | 1268 | | |
1244 | 1269 | | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
1245 | 1281 | | |
| 1282 | + | |
1246 | 1283 | | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
1247 | 1297 | | |
1248 | 1298 | | |
1249 | 1299 | | |
| |||
1258 | 1308 | | |
1259 | 1309 | | |
1260 | 1310 | | |
| 1311 | + | |
| 1312 | + | |
1261 | 1313 | | |
1262 | 1314 | | |
1263 | 1315 | | |
| |||
1272 | 1324 | | |
1273 | 1325 | | |
1274 | 1326 | | |
1275 | | - | |
1276 | | - | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
1277 | 1335 | | |
1278 | 1336 | | |
1279 | 1337 | | |
| |||
2018 | 2076 | | |
2019 | 2077 | | |
2020 | 2078 | | |
| 2079 | + | |
| 2080 | + | |
| 2081 | + | |
| 2082 | + | |
| 2083 | + | |
| 2084 | + | |
| 2085 | + | |
| 2086 | + | |
2021 | 2087 | | |
2022 | 2088 | | |
2023 | 2089 | | |
2024 | 2090 | | |
| 2091 | + | |
2025 | 2092 | | |
2026 | 2093 | | |
2027 | 2094 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
338 | 339 | | |
339 | 340 | | |
340 | 341 | | |
341 | | - | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
342 | 352 | | |
343 | 353 | | |
344 | 354 | | |
| |||
367 | 377 | | |
368 | 378 | | |
369 | 379 | | |
| 380 | + | |
370 | 381 | | |
371 | 382 | | |
372 | 383 | | |
| |||
479 | 490 | | |
480 | 491 | | |
481 | 492 | | |
| 493 | + | |
482 | 494 | | |
483 | 495 | | |
484 | 496 | | |
| |||
496 | 508 | | |
497 | 509 | | |
498 | 510 | | |
| 511 | + | |
499 | 512 | | |
500 | 513 | | |
501 | 514 | | |
| |||
569 | 582 | | |
570 | 583 | | |
571 | 584 | | |
| 585 | + | |
572 | 586 | | |
573 | 587 | | |
574 | 588 | | |
| |||
Lines changed: 59 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
9 | 17 | | |
10 | 18 | | |
11 | 19 | | |
| |||
29 | 37 | | |
30 | 38 | | |
31 | 39 | | |
| 40 | + | |
32 | 41 | | |
33 | 42 | | |
34 | 43 | | |
| |||
121 | 130 | | |
122 | 131 | | |
123 | 132 | | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
124 | 141 | | |
125 | 142 | | |
126 | 143 | | |
| |||
144 | 161 | | |
145 | 162 | | |
146 | 163 | | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
147 | 172 | | |
148 | 173 | | |
149 | 174 | | |
| |||
166 | 191 | | |
167 | 192 | | |
168 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
169 | 202 | | |
170 | 203 | | |
171 | 204 | | |
| |||
182 | 215 | | |
183 | 216 | | |
184 | 217 | | |
| 218 | + | |
185 | 219 | | |
186 | 220 | | |
187 | 221 | | |
| |||
237 | 271 | | |
238 | 272 | | |
239 | 273 | | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
240 | 282 | | |
241 | 283 | | |
242 | 284 | | |
| |||
298 | 340 | | |
299 | 341 | | |
300 | 342 | | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
301 | 351 | | |
302 | 352 | | |
303 | 353 | | |
| |||
314 | 364 | | |
315 | 365 | | |
316 | 366 | | |
| 367 | + | |
317 | 368 | | |
318 | 369 | | |
319 | 370 | | |
| |||
369 | 420 | | |
370 | 421 | | |
371 | 422 | | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
372 | 431 | | |
373 | 432 | | |
374 | 433 | | |
| |||
0 commit comments