Add disabled to accessibilityTraits in case button is disabled

Reviewed By: javache

Differential Revision: D4593622

fbshipit-source-id: 211f90f6af531a577af4e5487b43a3870f725bff
This commit is contained in:
Archit Pal Singh Sachdeva 2017-02-22 13:10:55 -08:00 committed by Facebook Github Bot
parent fd4ad6ca82
commit 813f873320
1 changed files with 5 additions and 1 deletions

View File

@ -111,11 +111,15 @@ class Button extends React.Component {
'The title prop of a Button must be a string', 'The title prop of a Button must be a string',
); );
const formattedTitle = Platform.OS === 'android' ? title.toUpperCase() : title; const formattedTitle = Platform.OS === 'android' ? title.toUpperCase() : title;
const accessibilityTraits = ['button'];
if (disabled) {
accessibilityTraits.push('disabled');
}
return ( return (
<Touchable <Touchable
accessibilityComponentType="button" accessibilityComponentType="button"
accessibilityLabel={accessibilityLabel} accessibilityLabel={accessibilityLabel}
accessibilityTraits={['button']} accessibilityTraits={accessibilityTraits}
testID={testID} testID={testID}
disabled={disabled} disabled={disabled}
onPress={onPress}> onPress={onPress}>