Skip to content

Commit

Permalink
fix(#310): missing a11y label and hint props on iOS Picker (#582)
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusz1913 authored Sep 20, 2024
1 parent 95879c2 commit ed2c679
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
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

0 comments on commit ed2c679

Please sign in to comment.