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

fix(#310): missing a11y label and hint props on iOS Picker #582

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion ios/RNCPicker.mm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#import <React/RCTConvert.h>
#import <React/RCTUtils.h>

@interface RNCPicker() <UIPickerViewDataSource, UIPickerViewDelegate>
@interface RNCPicker() <UIPickerViewDataSource, UIPickerViewDelegate, UIPickerViewAccessibilityDelegate>
@end

@implementation RNCPicker
Expand Down Expand Up @@ -147,6 +147,19 @@ - (void)pickerView:(__unused UIPickerView *)pickerView
}
}

#pragma mark - UIPickerViewAccessibilityDelegate

- (NSString *)pickerView:(UIPickerView *)pickerView accessibilityLabelForComponent:(NSInteger)component
{
return self.accessibilityLabel;
}

- (NSString *)pickerView:(UIPickerView *)pickerView accessibilityHintForComponent:(NSInteger)component
{
return self.accessibilityHint;
}


#ifdef RCT_NEW_ARCH_ENABLED
- (void)pickerView:(__unused UIPickerView *)pickerView
didSelectRow:(NSInteger)row inComponent:(__unused NSInteger)component
Expand Down
4 changes: 4 additions & 0 deletions js/PickerIOS.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ const PickerIOSWithForwardedRef: React.AbstractComponent<
onChange,
onValueChange,
style,
accessibilityLabel,
accessibilityHint,
} = props;

const nativePickerRef = React.useRef<React.ElementRef<
Expand Down Expand Up @@ -199,6 +201,8 @@ const PickerIOSWithForwardedRef: React.AbstractComponent<
ref={ref}
themeVariant={themeVariant}
testID={testID}
accessibilityLabel={accessibilityLabel}
accessibilityHint={accessibilityHint}
style={[styles.pickerIOS, itemStyle]}
// $FlowFixMe
items={items}
Expand Down
Loading