Skip to content

Commit

Permalink
Added Support for Entrance/exit from collection by Flatlist (#31630)
Browse files Browse the repository at this point in the history
Summary:
Issue #30964 .When using a screen reader, flatlist does not announce entrance/ exit from the flat list.

## Changelog

[Android] [Changed] - Added support for accessibility role of "list" for flatlist and sectioned list

Pull Request resolved: #31630

Test Plan: I have added accessibility role prop in flatlist and sectioned list in rntester app, that will announce entrance/ exit from flatlist and sectioned list.

Reviewed By: kacieb

Differential Revision: D29599351

Pulled By: blavalla

fbshipit-source-id: e16ec69a694780d12f15f88a1e6bb5d7d77ac15f
  • Loading branch information
anaskhraza authored and facebook-github-bot committed Jul 10, 2021
1 parent 157d595 commit 25a1612
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions Libraries/Components/View/ViewAccessibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export type AccessibilityRole =
| 'tab'
| 'tablist'
| 'timer'
| 'list'
| 'toolbar';

// the info associated with an accessibility action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ module.exports = {
'tab',
'tablist',
'timer',
'list',
'toolbar',
],
};
1 change: 1 addition & 0 deletions React/Views/RCTViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ @implementation RCTConvert (UIAccessibilityTraits)
@"tablist" : @(UIAccessibilityTraitNone),
@"timer" : @(UIAccessibilityTraitNone),
@"toolbar" : @(UIAccessibilityTraitNone),
@"list" : @(UIAccessibilityTraitNone),
}),
UIAccessibilityTraitNone,
unsignedLongLongValue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public enum AccessibilityRole {
TAB,
TABLIST,
TIMER,
LIST,
TOOLBAR;

public static String getValue(AccessibilityRole role) {
Expand Down Expand Up @@ -135,6 +136,8 @@ public static String getValue(AccessibilityRole role) {
return "android.widget.SpinButton";
case SWITCH:
return "android.widget.Switch";
case LIST:
return "android.widget.AbsListView";
case NONE:
case LINK:
case SUMMARY:
Expand Down
1 change: 1 addition & 0 deletions packages/rn-tester/js/examples/FlatList/FlatListExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ class FlatListExample extends React.PureComponent<Props, State> {
getItemLayout={
this.state.fixedHeight ? this._getItemLayout : undefined
}
accessibilityRole="list"
horizontal={this.state.horizontal}
inverted={this.state.inverted}
key={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ export function SectionList_scrollable(Props: {
ItemSeparatorComponent={info => (
<CustomSeparatorComponent {...info} text="ITEM SEPARATOR" />
)}
accessibilityRole="list"
debug={debug}
inverted={inverted}
disableVirtualization={!virtualized}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ const SectionListBaseExample: React.AbstractComponent<
<SectionList
ref={ref}
testID="section_list"
accessibilityRole="list"
sections={DATA}
keyExtractor={(item, index) => item + index}
style={styles.list}
Expand Down

0 comments on commit 25a1612

Please sign in to comment.