diff --git a/Libraries/Components/View/View.js b/Libraries/Components/View/View.js index 651fd092f0eead..b32e9500155b37 100644 --- a/Libraries/Components/View/View.js +++ b/Libraries/Components/View/View.js @@ -23,6 +23,11 @@ const ViewStylePropTypes = require('ViewStylePropTypes'); const invariant = require('fbjs/lib/invariant'); +const { + AccessibilityComponentTypes, + AccessibilityTraits, +} = require('ViewAccessibility'); + var TVViewPropTypes = {}; if (Platform.isTVOS) { TVViewPropTypes = require('TVViewPropTypes'); @@ -34,39 +39,12 @@ const PropTypes = React.PropTypes; const stylePropType = StyleSheetPropType(ViewStylePropTypes); -const AccessibilityTraits = [ - 'none', - 'button', - 'link', - 'header', - 'search', - 'image', - 'selected', - 'plays', - 'key', - 'text', - 'summary', - 'disabled', - 'frequentUpdates', - 'startsMedia', - 'adjustable', - 'allowsDirectInteraction', - 'pageTurn', -]; - -const AccessibilityComponentType = [ - 'none', - 'button', - 'radiobutton_checked', - 'radiobutton_unchecked', -]; - const forceTouchAvailable = (NativeModules.IOSConstants && NativeModules.IOSConstants.forceTouchAvailable) || false; const statics = { AccessibilityTraits, - AccessibilityComponentType, + AccessibilityComponentType: AccessibilityComponentTypes, /** * Is 3D Touch / Force Touch available (i.e. will touch events include `force`) * @platform ios @@ -169,7 +147,7 @@ const View = React.createClass({ * * @platform android */ - accessibilityComponentType: PropTypes.oneOf(AccessibilityComponentType), + accessibilityComponentType: PropTypes.oneOf(AccessibilityComponentTypes), /** * Indicates to accessibility services whether the user should be notified diff --git a/Libraries/Components/View/ViewAccessibility.js b/Libraries/Components/View/ViewAccessibility.js new file mode 100644 index 00000000000000..c5f6c42e3221aa --- /dev/null +++ b/Libraries/Components/View/ViewAccessibility.js @@ -0,0 +1,65 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule ViewAccessibility + * @flow + */ +'use strict'; + +export type AccessibilityTrait = + 'none' | + 'button' | + 'link' | + 'header' | + 'search' | + 'image' | + 'selected' | + 'plays' | + 'key' | + 'text' | + 'summary' | + 'disabled' | + 'frequentUpdates' | + 'startsMedia' | + 'adjustable' | + 'allowsDirectInteraction' | + 'pageTurn'; + +export type AccessibilityComponentType = + 'none' | + 'button' | + 'radiobutton_checked' | + 'radiobutton_unchecked'; + +module.exports = { + AccessibilityTraits: [ + 'none', + 'button', + 'link', + 'header', + 'search', + 'image', + 'selected', + 'plays', + 'key', + 'text', + 'summary', + 'disabled', + 'frequentUpdates', + 'startsMedia', + 'adjustable', + 'allowsDirectInteraction', + 'pageTurn', + ], + AccessibilityComponentTypes: [ + 'none', + 'button', + 'radiobutton_checked', + 'radiobutton_unchecked', + ], +}; diff --git a/React/Views/RCTPicker.m b/React/Views/RCTPicker.m index ce8598b48d4a0b..0e5295a9427e29 100644 --- a/React/Views/RCTPicker.m +++ b/React/Views/RCTPicker.m @@ -98,7 +98,7 @@ - (void)pickerView:(__unused UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(__unused NSInteger)component { _selectedIndex = row; - if (_onChange) { + if (_onChange && _items.count > row) { _onChange(@{ @"newIndex": @(row), @"newValue": RCTNullIfNil(_items[row][@"value"]),