diff --git a/README.md b/README.md index 16311cb857..1ce1bebdad 100644 --- a/README.md +++ b/README.md @@ -396,6 +396,15 @@ If set to false, the specific item will be disabled, i.e. the user will not be a | boolean | no | Android | +### `contentDescription` + +Sets the content description to the Picker Item + +| Type | Required | Platform | +| ------ | -------- | -------- | +| string | No | Android | + + ### PickerIOS ### Props diff --git a/android/src/main/java/com/reactnativecommunity/picker/ReactPickerManager.java b/android/src/main/java/com/reactnativecommunity/picker/ReactPickerManager.java index 0ac93878a3..02c06113cc 100644 --- a/android/src/main/java/com/reactnativecommunity/picker/ReactPickerManager.java +++ b/android/src/main/java/com/reactnativecommunity/picker/ReactPickerManager.java @@ -295,6 +295,10 @@ private View getView(int position, View convertView, ViewGroup parent, boolean i textView.setTextColor(item.getInt("color")); } + if (item.hasKey("contentDescription") && !item.isNull("contentDescription")) { + textView.setContentDescription(item.getString("contentDescription")); + } + if (item.hasKey("fontFamily") && !item.isNull("fontFamily")) { Typeface face = Typeface.create(item.getString("fontFamily"), Typeface.NORMAL); textView.setTypeface(face); diff --git a/js/PickerAndroid.android.js b/js/PickerAndroid.android.js index 6ab670bb35..c58fa3b8ab 100644 --- a/js/PickerAndroid.android.js +++ b/js/PickerAndroid.android.js @@ -94,12 +94,13 @@ function PickerAndroid(props: PickerAndroidProps, ref: PickerRef): React.Node { const {enabled = true} = child.props; - const {color, label, style = {}} = child.props; + const {color, contentDescription, label, style = {}} = child.props; const processedColor = processColor(color); return { color: color == null ? null : processedColor, + contentDescription, label, enabled, style: { diff --git a/js/types.js b/js/types.js index a7b1114483..4aee14c2a5 100644 --- a/js/types.js +++ b/js/types.js @@ -20,6 +20,7 @@ export type PickerItem = $ReadOnly<{| label: string, value: ?(number | string), color?: ?number, + contentDescription?: ?string, fontFamily: ?string, /** * Style to apply to individual item labels.