Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android: Position in Collection not supported by Flatlist, SectionList, VirtualizedList, or ScrollView #6

Closed
fabOnReact opened this issue Feb 8, 2022 · 32 comments

Comments

@fabOnReact
Copy link
Owner

fabOnReact commented Feb 8, 2022

Issue facebook/react-native#30977
Pull Request facebook/react-native#33180
Related facebook/react-native#31666

@fabOnReact

This comment was marked as resolved.

@fabOnReact
Copy link
Owner Author

fabOnReact commented Feb 8, 2022

<FlatList numColumns={undefined} /> should not trigger Runtime Error NoSuchKey exception columnCount when enabling TalkBack.

<FlatList numColumns={undefined} />

Expected Result:
No Runtime Error

Actual Result:
Enabling TalkBack triggers a Runtime Error NoSuchKeyException columnCount

CLICK TO OPEN RUNTIME ERROR

CLICK TO OPEN DETAILS

https://github.com/fabriziobertoglio1987/react-native/blob/e36f46a003a0c279d6d7e84bdfefc0b1a61d5cb7/Libraries/Lists/FlatList.js#L671-L675

https://github.com/fabriziobertoglio1987/react-native/blob/e36f46a003a0c279d6d7e84bdfefc0b1a61d5cb7/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java#L201

numColums default was removed with commit 7d5895d

CLICK TO OPEN TESTS RESULTS - WITHOUT RUNTIME

numColumnsNoRuntime.mp4

CLICK TO OPEN TESTS RESULTS - WITH RUNTIME

numColumnsRuntime.mp4

Solved with fabOnReact/react-native@062cdcd

@fabOnReact fabOnReact pinned this issue Feb 8, 2022
@fabOnReact

This comment was marked as off-topic.

@fabOnReact
Copy link
Owner Author

fabOnReact commented Feb 9, 2022

Scenarios Previously Tested in facebook/react-native#31666 (comment) (VIDEO1 and VIDEO2)

  • Horizontal FlatList
  • Vertical FlatList
  • Horizontal FlatList
  • Horizontal FlatList when fixed layout
  • FlatList when numColumns > 1
  • FlatList when numColumns > 1 and fixed layout
  • Simple 1 column FlatList
  • Simple 1 column FlatList - Fixed layout
  • Nested FlatList

New Scenarios

@fabOnReact

This comment was marked as off-topic.

@fabOnReact
Copy link
Owner Author

fabOnReact commented Feb 11, 2022

Columns in FlatList with multiple columns are not announced

  • A blind user uses TalkBack to navigate items in the FlatList.
  • The FlatList has 2 columns and 6 rows (grid layout)
  • TalkBack announces each of the items and their column and row number

Expected Result:
Talkback announces:

  1. Marketplace row 1 column 1
  2. FriendsList row 1 column 2
  3. Groups row 2 column 1
  4. Pages row 2 column 2
  5. Fifth Item row 3 column 1
  6. Sixth Item row 3 column 2

Actual Result:
Talkback announces:

  1. Marketplace row 1
  2. FriendsList
  3. Groups row 2
  4. Pages
  5. Fifth Item row 3
  6. Sixth Item

The TalkBack announcements are correct when using 1 column.

CLICK TO OPEN EXAMPLE

data

const DATA = [
  {
    id: 'bd7acbea-c1b1-46c2-aed5-3ad53abb28ba',
    title: 'Marketplace',
  },
  {
    id: '3ac68afc-c605-48d3-a4f8-fbd91aa97f63',
    title: 'FriendsList',
  },
  {
    id: '58694a0f-3da1-471f-bd96-145571e29d72',
    title: 'Groups',
  },
  {
    id: 'bd7acbea-c1b1-46c2-aed5-3ad53abb8bbb',
    title: 'Pages',
  },
  {
    id: '3ac68afc-c605-48d3-a4f8-fbd91aa97676',
    title: 'Fifth Item',
  },
  {
    id: '58694a0f-3da1-471f-bd96-145571e27234',
    title: 'Sixth Item',
  },
];
// and more items

JSX

<>
      <FlatList
        keyExtractor={item => item.id}
        numColumns={2}
        pagingEnabled={true}
        data={DATA}
        renderItem={renderItem}
        keyExtractor={item => item.toString()}
      />
</>

CLICK TO OPEN TESTS RESULTS - EXPECTED BEHAVIOUR

gridViewExpectedBehaviour.mp4

CLICK TO OPEN TESTS RESULTS - ACTUAL BEHAVIOUR

columnsInSpanNotAnnounced.mp4

@fabOnReact
Copy link
Owner Author

fabOnReact commented Feb 11, 2022

SOLUTION FOR ISSUE #6 (comment)

The issue is caused by this 2 lines. Commenting them and replacing them with a random integer number fixes the issue.

https://github.com/fabriziobertoglio1987/react-native-notes/blob/875076952dc8658d2cd61026411dbc24e05e90a3/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java#L210-L211

  • The correct column numbers are announced when moving between different columns.
  • The correct row numbers are announced when moving between different rows.
CLICK TO OPEN VIDEO - NOT ANNOUNCING COLUMN

notAnnouncingColumn.mp4

CLICK TO OPEN VIDEO - ANNOUNCING COLUMN

announcingColumn.mp4

CLICK TO OPEN VIDEO - ANNOUNCING COLUMN AND ROW

announcingColumnAndRow.mp4

CLICK TO OPEN VIDEO - SCROLL PAGE BEFORE

With 3 columns - Before the Change

verifyBehaviourWithoutChange.mp4
CLICK TO OPEN VIDEO - SCROLL PAGE AFTER

With 3 columns - After the Change

notAnnouncingCorrectListCount.mp4
CLICK TO OPEN MORE INFO

Removing the lines below (or replacing grid with list) would remove the row/column announcement.

https://github.com/fabriziobertoglio1987/react-native-notes/blob/875076952dc8658d2cd61026411dbc24e05e90a3/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.java#L409

https://github.com/fabriziobertoglio1987/react-native-notes/blob/875076952dc8658d2cd61026411dbc24e05e90a3/Libraries/Lists/FlatList.js#L698

more info at #6 (comment)

The index is set correctly for columns 1 and 2, but TalkBack does not announce them.

https://github.com/fabriziobertoglio1987/react-native-notes/blob/875076952dc8658d2cd61026411dbc24e05e90a3/Libraries/Lists/FlatList.js#L620

https://github.com/fabriziobertoglio1987/react-native-notes/blob/875076952dc8658d2cd61026411dbc24e05e90a3/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.java#L237

The reason is that our Java Implementation of FlatList numColums does not use GridView, but simply uses ScrollView formatting data as a 2 columns table.

https://github.com/fabriziobertoglio1987/react-native-notes/blob/875076952dc8658d2cd61026411dbc24e05e90a3/Libraries/Lists/FlatList.js#L492-L506

https://github.com/fabriziobertoglio1987/react-native-notes/blob/875076952dc8658d2cd61026411dbc24e05e90a3/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java#L67

https://github.com/aosp-mirror/platform_frameworks_base/blob/1ac46f932ef88a8f96d652580d8105e361ffc842/core/java/android/widget/ScrollView.java#L56-L80

https://github.com/aosp-mirror/platform_frameworks_base/blob/1ac46f932ef88a8f96d652580d8105e361ffc842/core/java/android/widget/GridView.java#L54-L69

https://github.com/fabriziobertoglio1987/react-native-notes/blob/875076952dc8658d2cd61026411dbc24e05e90a3/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.java#L146

Removing the above line:

  • TalkBack announces the item when scrolling pages
  • Rows are not announced anymore

Adding the accessibilityRole grid adds the announcement for the rows.

CLICK TO OPEN TESTS RESULTS

removingRole.mp4

@fabOnReact

This comment was marked as off-topic.

@fabOnReact

This comment was marked as duplicate.

@fabOnReact

This comment was marked as resolved.

@fabOnReact

This comment was marked as off-topic.

fabOnReact added a commit to fabOnReact/react-native that referenced this issue Feb 15, 2022
fabOnReact added a commit to fabOnReact/react-native that referenced this issue Feb 15, 2022
fabOnReact added a commit to fabOnReact/react-native that referenced this issue Feb 15, 2022
@fabOnReact
Copy link
Owner Author

fabOnReact commented Feb 15, 2022

Using height instead of width

Solves #6 (comment) #6 (comment).
The method from ReactHorizontalScrollView scrolls in a different direction.
computeScrollDeltaToGetChildRectOnScreen is inherited from ScrollView. Video of the tests in #6 (comment).

  private boolean isPartiallyScrolledInView(View descendent) {
    int scrollDelta = getScrollDelta(descendent);
    descendent.getDrawingRect(mTempRect);
    return scrollDelta != 0 && Math.abs(scrollDelta) < mTempRect.height();
  }

@fabOnReact

This comment was marked as off-topic.

@fabOnReact

This comment was marked as off-topic.

@fabOnReact
Copy link
Owner Author

fabOnReact commented Feb 16, 2022

Not announcing correctly the last page (partial scroll)

Solves #6 (comment) #6 (comment).
The issue was caused by ScrollDelta with value 0 (solved with fabOnReact/react-native@ee23f45).

2022-02-16.12-51-16.mp4

@fabOnReact
Copy link
Owner Author

fabOnReact commented Feb 17, 2022

TalkBack announces pages when scrolling down a GridView

TalkBack announces showing item 10 to 21 of 29 when scrolling pages in a GridView.

fabOnReact/MyApplication@0bfa67e

2022-02-17.10-52-22.mp4

@fabOnReact

This comment was marked as off-topic.

@fabOnReact

This comment was marked as off-topic.

@fabOnReact

This comment was marked as off-topic.

@fabOnReact

This comment was marked as off-topic.

@fabOnReact

This comment was marked as off-topic.

fabOnReact added a commit to fabOnReact/react-native that referenced this issue Feb 24, 2022
@fabOnReact
Copy link
Owner Author

fabOnReact commented Feb 25, 2022

TalkBack announces pages and cells with Horizontal Flatlist in the Paper Renderer

Expected/Actual Result:
Talkback announces the selected item row and column changes:

  1. 1 Item one of 29
  2. 2 Item two of 29

Expected/Actual Result:
Talkback announces the pages when scrolling down:

Thirteen Item row 5 column 1 then says showing item 2 to 4 of 29
CLICK TO OPEN SOURCECODE

https://github.com/fabriziobertoglio1987/ReactNativeAwesomeProject/blob/af0d0baa95f4520cd05d61031a69a66ec8521bf0/App.js

<FlatList
  horizontal={true}
  data={DATA}
  renderItem={renderFlatList}
  keyExtractor={item => item.toString()}
/>
const Item = ({title}) => (
  <View style={styles.item}>
    <Text style={styles.title}>{title}</Text>
  </View>
);

const renderFlatList = ({item}) => (
  <View>
    <Item title={item.title} />
  </View>
);
data used in flatlist

const DATA = [
  {
    id: '1',
    title: '1 Item',
  },
  {
    id: '2',
    title: '2 Item',
  },
  {
    id: '3',
    title: '3 Item',
  },
  {
    id: '4',
    title: '4 Item',
  },
  {
    id: '5',
    title: 'Fifth Item',
  },
  {
    id: '6',
    title: 'Sixth Item',
  },
  {
    id: '7',
    title: 'Seven Item',
  },
  {
    id: '8',
    title: 'Eight Item',
  },
  {
    id: '9',
    title: 'Nine Item',
  },
  {
    id: '10',
    title: 'Ten Item',
  },
  {
    id: '11',
    title: 'Eleven Item',
  },
  {
    id: '12',
    title: 'Twelve Item',
  },
  {
    id: '13',
    title: 'Thirdteen Item',
  },
  {
    id: '14',
    title: 'Fourteen Item',
  },
  {
    id: '15',
    title: 'Fifthteen Item',
  },
  {
    id: '16',
    title: 'Sixteen Item',
  },
  {
    id: '17',
    title: '17 Item',
  },
  {
    id: '18',
    title: '18 Item',
  },
  {
    id: '19',
    title: '19 Item',
  },
  {
    id: '20',
    title: '20 Item',
  },
  {
    id: '21',
    title: '21 Item',
  },
  {
    id: '22',
    title: '22 Item',
  },
  {
    id: '21',
    title: '23 Item',
  },
  {
    id: '22',
    title: '24 Item',
  },
  {
    id: '22',
    title: '25 Item',
  },
  {
    id: '23',
    title: '26 Item',
  },
  {
    id: '24',
    title: '27 Item',
  },
  {
    id: '25',
    title: '28 Item',
  },
  {
    id: '26',
    title: '29 Item',
  },
];

CLICK TO OPEN VIDEO TESTS

2022-02-25.10-15-30.mp4

@fabOnReact
Copy link
Owner Author

fabOnReact commented Feb 25, 2022

TalkBack announces pages and cells with Vertical Flatlist in the Paper Renderer

Expected/Actual Result:
Talkback announces the selected item row and column changes:

  1. 2 Item column 2
  2. 4 Item row two column 1
  3. 11 Item column 2

Expected/Actual Result:
Talkback announces the pages when scrolling down:

Showing Item 10 to 19 of 29
CLICK TO OPEN SOURCECODE

fabOnReact/ReactNativeAwesomeProject@016921e

class App extends React.Component {
  constructor(props) {
    super(props);
  }
  header = () => {
    return (
      <View>
        <Text>POSTS</Text>
      </View>
    );
  };
  render() {
    return (
      <FlatList
        accessible={true}
        accessibilityRole="grid"
        numColumns={3}
        keyExtractor={item => item.id}
        pagingEnabled={false}
        data={DATA}
        renderItem={renderItem}
        keyExtractor={item => item.toString()}
      />
    );
  }
}

const renderItem = ({item, key}) => (
  <View key={key} style={styles.item}>
    <Text key={key}>{item.title}</Text>
  </View>
);
const Item = ({title}) => (
  <View style={styles.item}>
    <Text style={styles.title}>{title}</Text>
  </View>
);

const renderFlatList = ({item}) => (
  <View>
    <Item title={item.title} />
  </View>
);
data used in flatlist

const DATA = [
  {
    id: '1',
    title: '1 Item',
  },
  {
    id: '2',
    title: '2 Item',
  },
  {
    id: '3',
    title: '3 Item',
  },
  {
    id: '4',
    title: '4 Item',
  },
  {
    id: '5',
    title: 'Fifth Item',
  },
  {
    id: '6',
    title: 'Sixth Item',
  },
  {
    id: '7',
    title: 'Seven Item',
  },
  {
    id: '8',
    title: 'Eight Item',
  },
  {
    id: '9',
    title: 'Nine Item',
  },
  {
    id: '10',
    title: 'Ten Item',
  },
  {
    id: '11',
    title: 'Eleven Item',
  },
  {
    id: '12',
    title: 'Twelve Item',
  },
  {
    id: '13',
    title: 'Thirdteen Item',
  },
  {
    id: '14',
    title: 'Fourteen Item',
  },
  {
    id: '15',
    title: 'Fifthteen Item',
  },
  {
    id: '16',
    title: 'Sixteen Item',
  },
  {
    id: '17',
    title: '17 Item',
  },
  {
    id: '18',
    title: '18 Item',
  },
  {
    id: '19',
    title: '19 Item',
  },
  {
    id: '20',
    title: '20 Item',
  },
  {
    id: '21',
    title: '21 Item',
  },
  {
    id: '22',
    title: '22 Item',
  },
  {
    id: '21',
    title: '23 Item',
  },
  {
    id: '22',
    title: '24 Item',
  },
  {
    id: '22',
    title: '25 Item',
  },
  {
    id: '23',
    title: '26 Item',
  },
  {
    id: '24',
    title: '27 Item',
  },
  {
    id: '25',
    title: '28 Item',
  },
  {
    id: '26',
    title: '29 Item',
  },
];

CLICK TO OPEN VIDEO TESTS

2022-02-25.10-35-37.mp4

@fabOnReact

This comment was marked as resolved.

@fabOnReact
Copy link
Owner Author

fabOnReact commented Feb 25, 2022

TalkBack announces pages and cells with Nested Horizontal Flatlist in the rn-tester app

Expected/Actual Result:
Talkback announces the selected item row and column changes:

  1. 2 Item column 2
  2. 4 Item row two column 1
  3. 11 Item column 2

Expected/Actual Result:
Talkback announces the pages when scrolling down:

Showing Item 10 to 19 of 29
CLICK TO OPEN VIDEO TESTS

2022-02-25.15-52-46.mp4

@fabOnReact
Copy link
Owner Author

fabOnReact commented Mar 11, 2022

facebook/react-native#33180 (comment)

Screenshots of the two scenarios (with and without {flex: 1})

without {flex: 1} with {flex: 1}

I moved this logic to VirtualizedList with commits move accessibilityCollectionItem logic to VirtList, Move Logic to virtualized list and removing container View in renderItem callback removing the View container around the cell.

The callback renderItem now has the accessibilityCollectionItem.

Example of the implementation with FlatList

https://github.com/facebook/react-native/blob/c0893d20470e5971eaee5ccc74196dbe8ec84770/packages/rn-tester/js/examples/FlatList/FlatList-multiColumn.js#L143-L156

I added the prop type accessibilityCollectionItem to the View Component, which is used in this case as a wrapper around each FlatList/SectionList cell.

accessibilityCollectionItem in ViewPropTypes

https://github.com/facebook/react-native/blob/c0893d20470e5971eaee5ccc74196dbe8ec84770/Libraries/Components/View/ViewPropTypes.js#L444-L459

The previous solution was adding a wrapper View Component around each cell.
The wrapper in VirtualizedList spans for the entire row (explanation in this post) and does not work with multicolumn flatlist.

I would like to receive your feedback on this solution before investing further time. Is this the solution you had in mind? I can revert this changes or improve it based on your feedback. Thanks

@fabOnReact

This comment was marked as duplicate.

@fabOnReact

This comment was marked as duplicate.

@fabOnReact

This comment was marked as resolved.

fabOnReact added a commit to fabOnReact/react-native that referenced this issue Mar 13, 2022
facebook#33180 (comment)
>What's the reason for adding this cellStyle here?

- we are adding a [View container][1] to each [cell][2] ([renderItem prop][3])
- `{flex: 1}` makes the container View take the full width of the parent container

https://reactnative.dev/docs/flexbox#flex

>[flex](https://reactnative.dev/docs/layout-props#flex) will define how your items are going to “fill” over the available space along your main axis. Space will be divided according to each element's flex property.

| without `{flex: 1}` | with `{flex: 1}` |
|:-------------------------:|:-------------------------:|
| <img src="https://user-images.githubusercontent.com/24992535/157849508-1958558b-f3b1-4ae1-ab4e-a36c1991ad78.png" width="250" />| <img src="https://user-images.githubusercontent.com/24992535/157849671-7382a7a8-3299-4b88-ab94-7b1c5b8eb9ec.png" width="250" /> |

[1]: https://github.com/fabriziobertoglio1987/react-native/blob/70e83a2cbb4f81ea373f3876abd9caf9f35a50a3/Libraries/Lists/FlatList.js#L628-L630 "the View container added to each cell"
[2]: https://github.com/fabriziobertoglio1987/react-native/blob/70e83a2cbb4f81ea373f3876abd9caf9f35a50a3/Libraries/Lists/FlatList.js#L581-L601 "the logic responsible to render cells (renderItem prop)"
[3]: https://reactnative.dev/docs/next/flatlist#required-renderitem  "renderItem prop"

original post fabOnReact/react-native-notes#6 (comment)
fabOnReact added a commit to fabOnReact/react-native that referenced this issue Mar 13, 2022
- remove the wrapper View and cellstyle flex: 1
- add prop accessibilityCollectionItem to FlatList renderItem to allow
  users set the accessibilityInformation
- update rn-tester flatlist examples

Follow up of 1a98f56
Related fabOnReact/react-native-notes#6 (comment)
fabOnReact added a commit to fabOnReact/react-native that referenced this issue Mar 13, 2022
fabOnReact added a commit to fabOnReact/react-native that referenced this issue Mar 14, 2022
further info at fabOnReact/react-native-notes#6 (comment)
- Adds support for SectionList, VirtualizedList
- Sharing common logic between components

The accessibilityCollectionItem is calculated in the VirtualizedList and
passed as a 4th parameter to renderItem function

https://github.com/fabriziobertoglio1987/react-native-notes/blob/f49caa490eb2378466bfa3eeb672aa6eab5b65b7/Libraries/Lists/VirtualizedList.js#L1995-L2023
```javascript
renderItem({
  item,
    index,
    separators: this._separators,
    accessibilityCollectionItem,
});
```

adding accessibilityCollectionItem would make the FlatList cell or
VirtualizedList row announce row 1 column 1, row 2 column 2 ...
https://reactnative.dev/docs/next/flatlist#required-renderitem

The main difference between FlatList and VirtualizedList is that
FlatList can have numColumns > 1 and the computation of
accessibilityCollectionItem is changed in the FlatList based on the
numColumns value.

TODO
- Move logic to ScrollView and add support for ScrollView
- Add accessibilityCollectionItem prop to View. The user can change this
  prop and it is part of the public API
facebook-github-bot pushed a commit to facebook/react-native that referenced this issue Apr 20, 2022
… grid) (#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: #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]: #30977
[18]: fabOnReact/react-native-notes#6
[19]: #31666
[20]: https://reactnative.dev/docs/next/flatlist#required-renderitem "FlatList renderItem documentation"
[21]: fabOnReact@7514735 "commit that introduces fourth param accessibilityCollectionItem in callback renderItem"
[22]: #33180 (comment) "discussion on the additional container View around each FlatList cell"
[23]: fabOnReact@d50fd1a "commit adding prop getCellsInItemCount to VirtualizedList"

Reviewed By: kacieb

Differential Revision: D34518929

Pulled By: blavalla

fbshipit-source-id: 410a05263a56162bf505a4cad957b24005ed65ed
facebook-github-bot pushed a commit to facebook/react-native that referenced this issue Jun 16, 2022
… grid) - JAVA ONLY CHANGES (#33180)

Summary:
This is the Java-only changes from D34518929 (dd6325b), split out for push safety. Original summary and test plan below:

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: #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]: #30977
[18]: fabOnReact/react-native-notes#6
[19]: #31666
[20]: https://reactnative.dev/docs/next/flatlist#required-renderitem "FlatList renderItem documentation"
[21]: fabOnReact@7514735 "commit that introduces fourth param accessibilityCollectionItem in callback renderItem"
[22]: #33180 (comment) "discussion on the additional container View around each FlatList cell"
[23]: fabOnReact@d50fd1a "commit adding prop getCellsInItemCount to VirtualizedList"

Reviewed By: kacieb

Differential Revision: D37186697

Pulled By: blavalla

fbshipit-source-id: 7bb95274326ded417c6f1365cc8633391f589d1a
facebook-github-bot pushed a commit to facebook/react-native that referenced this issue Jun 18, 2022
… grid) - Javascript Only Changes (#33180)

Summary:
This is the Javascript-only changes from D34518929 (dd6325b), split out for push safety. Original summary and test plan below:

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: #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]: #30977
[18]: fabOnReact/react-native-notes#6
[19]: #31666
[20]: https://reactnative.dev/docs/next/flatlist#required-renderitem "FlatList renderItem documentation"
[21]: fabOnReact@7514735 "commit that introduces fourth param accessibilityCollectionItem in callback renderItem"
[22]: #33180 (comment) "discussion on the additional container View around each FlatList cell"
[23]: fabOnReact@d50fd1a "commit adding prop getCellsInItemCount to VirtualizedList"

Reviewed By: kacieb

Differential Revision: D37189197

Pulled By: blavalla

fbshipit-source-id: 3765213c5d8bfde56e0e5f155cdd899c368512e7
facebook-github-bot pushed a commit to facebook/react-native that referenced this issue Aug 3, 2022
… grid) - Javascript Only Changes (#33180)

Summary:
This is the Javascript-only changes from D34518929 (dd6325b), split out for push safety. Original summary and test plan below:

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: #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]: #30977
[18]: fabOnReact/react-native-notes#6
[19]: #31666
[20]: https://reactnative.dev/docs/next/flatlist#required-renderitem "FlatList renderItem documentation"
[21]: fabOnReact@7514735 "commit that introduces fourth param accessibilityCollectionItem in callback renderItem"
[22]: #33180 (comment) "discussion on the additional container View around each FlatList cell"
[23]: fabOnReact@d50fd1a "commit adding prop getCellsInItemCount to VirtualizedList"

Reviewed By: lunaleaps

Differential Revision: D37668064

Pulled By: blavalla

fbshipit-source-id: 7ba4068405fdcb9823d0daed2d8c36f0a56dbf0f
roryabraham pushed a commit to Expensify/react-native that referenced this issue Aug 17, 2022
… grid) - Javascript Only Changes (facebook#33180)

Summary:
This is the Javascript-only changes from D34518929 (facebook@dd6325b), split out for push safety. Original summary and test plan below:

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]: fabOnReact@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]: fabOnReact@d50fd1a "commit adding prop getCellsInItemCount to VirtualizedList"

Reviewed By: lunaleaps

Differential Revision: D37668064

Pulled By: blavalla

fbshipit-source-id: 7ba4068405fdcb9823d0daed2d8c36f0a56dbf0f
roryabraham pushed a commit to Expensify/react-native that referenced this issue Aug 17, 2022
… grid) - Javascript Only Changes (facebook#33180)

Summary:
This is the Javascript-only changes from D34518929 (facebook@dd6325b), split out for push safety. Original summary and test plan below:

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]: fabOnReact@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]: fabOnReact@d50fd1a "commit adding prop getCellsInItemCount to VirtualizedList"

Reviewed By: lunaleaps

Differential Revision: D37668064

Pulled By: blavalla

fbshipit-source-id: 7ba4068405fdcb9823d0daed2d8c36f0a56dbf0f
Saadnajmi pushed a commit to Saadnajmi/react-native-macos that referenced this issue Jan 15, 2023
… 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]

[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]: fabOnReact@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]: fabOnReact@d50fd1a "commit adding prop getCellsInItemCount to VirtualizedList"

Reviewed By: kacieb

Differential Revision: D34518929

Pulled By: blavalla

fbshipit-source-id: 410a05263a56162bf505a4cad957b24005ed65ed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant