Skip to content

Commit a342740

Browse files
ArnonZethanshar
authored andcommitted
Fix/Accessibility - picker/item (#603)
* picker item accessibility tweaks * Lint * cosmetics
1 parent 65c2dc4 commit a342740

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/components/picker/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ class Picker extends BaseComponent {
166166
getAccessibilityInfo() {
167167
const {placeholder} = this.props;
168168
return {
169-
accessibilityLabel: this.getLabel() ? `${placeholder}. selected value = ${this.getLabel()}` : `Select ${placeholder}`,
169+
accessibilityLabel: this.getLabel() ? `${placeholder}. selected. ${this.getLabel()}` : `Select ${placeholder}`,
170170
accessibilityHint: this.getLabel()
171171
? 'Double tap to edit'
172172
: `Goes to ${placeholder}. Suggestions will be provided`,
@@ -196,7 +196,7 @@ class Picker extends BaseComponent {
196196
}
197197

198198
if (_.isPlainObject(value)) {
199-
return _.get(value, 'label');
199+
return _.get(value, 'label');
200200
}
201201

202202
// otherwise, extract from picker items
@@ -259,12 +259,14 @@ class Picker extends BaseComponent {
259259

260260
if (!showSearch || _.isEmpty(searchValue) || _.includes(_.lowerCase(childLabel), _.lowerCase(searchValue))) {
261261
const selectedValue = PickerPresenter.getItemValue({value, getItemValue});
262+
const isSelected = PickerPresenter.isItemSelected(childValue, selectedValue);
262263
return React.cloneElement(child, {
263-
isSelected: PickerPresenter.isItemSelected(childValue, selectedValue),
264+
isSelected,
264265
onPress: mode === Picker.modes.MULTI ? this.toggleItemSelection : this.onDoneSelecting,
265266
getItemValue: child.props.getItemValue || getItemValue,
266267
onSelectedLayout: this.onSelectedItemLayout,
267268
renderItem: child.props.renderItem || renderItem,
269+
accessibilityState: isSelected ? {selected: true} : undefined,
268270
accessibilityHint: 'Double click to select this suggestion'
269271
});
270272
}

0 commit comments

Comments
 (0)