Skip to content

Commit 93ba0c4

Browse files
authored
feat: Added content description prop to android items. (#482)
1 parent acf2375 commit 93ba0c4

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,15 @@ If set to false, the specific item will be disabled, i.e. the user will not be a
396396
| boolean | no | Android |
397397

398398

399+
### `contentDescription`
400+
401+
Sets the content description to the Picker Item
402+
403+
| Type | Required | Platform |
404+
| ------ | -------- | -------- |
405+
| string | No | Android |
406+
407+
399408
### PickerIOS
400409
### Props
401410

android/src/main/java/com/reactnativecommunity/picker/ReactPickerManager.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,10 @@ private View getView(int position, View convertView, ViewGroup parent, boolean i
295295
textView.setTextColor(item.getInt("color"));
296296
}
297297

298+
if (item.hasKey("contentDescription") && !item.isNull("contentDescription")) {
299+
textView.setContentDescription(item.getString("contentDescription"));
300+
}
301+
298302
if (item.hasKey("fontFamily") && !item.isNull("fontFamily")) {
299303
Typeface face = Typeface.create(item.getString("fontFamily"), Typeface.NORMAL);
300304
textView.setTypeface(face);

js/PickerAndroid.android.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,13 @@ function PickerAndroid(props: PickerAndroidProps, ref: PickerRef): React.Node {
9494

9595
const {enabled = true} = child.props;
9696

97-
const {color, label, style = {}} = child.props;
97+
const {color, contentDescription, label, style = {}} = child.props;
9898

9999
const processedColor = processColor(color);
100100

101101
return {
102102
color: color == null ? null : processedColor,
103+
contentDescription,
103104
label,
104105
enabled,
105106
style: {

js/types.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export type PickerItem = $ReadOnly<{|
2020
label: string,
2121
value: ?(number | string),
2222
color?: ?number,
23+
contentDescription?: ?string,
2324
fontFamily: ?string,
2425
/**
2526
* Style to apply to individual item labels.

0 commit comments

Comments
 (0)