Fix inability to remove 'Disabled' state from AccessibilityStates
Summary: D8842691 split AccessibilityTraits into multiple RN properties. However, the accessor code did not support REMOVING traits. This results in buttons that were disabled (AccessibilityTraits & NotEnabled === true) never being enabled. Fix the issue by making the split accessors properly mask in the bits, allowing you unset them without disturbing bits managed by the other accessor. NOTE: setting AccessibilityTraits and AccessibilityRole or AccessibilityStates will still result in bugs. Reviewed By: shergin Differential Revision: D9661970 fbshipit-source-id: 77d70dd0754f2eaf8cbf895bfc13757c697a76d8
This commit is contained in:
parent
bbc1af6536
commit
5eaa2d29c0
|
@ -80,6 +80,7 @@ module.exports = {
|
|||
'radiobutton_checked',
|
||||
'radiobutton_unchecked',
|
||||
],
|
||||
// This must be kept in sync with the AccessibilityRolesMask in RCTViewManager.m
|
||||
AccessibilityRoles: [
|
||||
'none',
|
||||
'button',
|
||||
|
@ -93,5 +94,6 @@ module.exports = {
|
|||
'header',
|
||||
'summary',
|
||||
],
|
||||
// This must be kept in sync with the AccessibilityStatesMask in RCTViewManager.m
|
||||
AccessibilityStates: ['selected', 'disabled'],
|
||||
};
|
||||
|
|
|
@ -151,12 +151,22 @@ RCT_CUSTOM_VIEW_PROPERTY(transform, CATransform3D, RCTView)
|
|||
|
||||
RCT_CUSTOM_VIEW_PROPERTY(accessibilityRole, UIAccessibilityTraits, RCTView)
|
||||
{
|
||||
view.reactAccessibilityElement.accessibilityTraits |= json ? [RCTConvert UIAccessibilityTraits:json] : defaultView.accessibilityTraits;
|
||||
// This mask must be kept in sync with the AccessibilityRoles enum defined in ViewAccessibility.js
|
||||
const UIAccessibilityTraits AccessibilityRolesMask = UIAccessibilityTraitNone | UIAccessibilityTraitButton | UIAccessibilityTraitLink | UIAccessibilityTraitSearchField | UIAccessibilityTraitImage | UIAccessibilityTraitKeyboardKey | UIAccessibilityTraitStaticText | UIAccessibilityTraitAdjustable | UIAccessibilityTraitHeader | UIAccessibilityTraitSummaryElement;
|
||||
|
||||
UIAccessibilityTraits newTraits = json ? [RCTConvert UIAccessibilityTraits:json] : defaultView.accessibilityTraits;
|
||||
UIAccessibilityTraits maskedTraits = newTraits & AccessibilityRolesMask;
|
||||
view.reactAccessibilityElement.accessibilityTraits = (view.reactAccessibilityElement.accessibilityTraits & ~AccessibilityRolesMask) | maskedTraits;
|
||||
}
|
||||
|
||||
RCT_CUSTOM_VIEW_PROPERTY(accessibilityStates, UIAccessibilityTraits, RCTView)
|
||||
{
|
||||
view.reactAccessibilityElement.accessibilityTraits |= json ? [RCTConvert UIAccessibilityTraits:json] : defaultView.accessibilityTraits;
|
||||
// This mask must be kept in sync with the AccessibilityStates enum defined in ViewAccessibility.js
|
||||
const UIAccessibilityTraits AccessibilityStatesMask = UIAccessibilityTraitNotEnabled | UIAccessibilityTraitSelected;
|
||||
|
||||
UIAccessibilityTraits newTraits = json ? [RCTConvert UIAccessibilityTraits:json] : defaultView.accessibilityTraits;
|
||||
UIAccessibilityTraits maskedTraits = newTraits & AccessibilityStatesMask;
|
||||
view.reactAccessibilityElement.accessibilityTraits = (view.reactAccessibilityElement.accessibilityTraits & ~AccessibilityStatesMask) | maskedTraits;
|
||||
}
|
||||
|
||||
RCT_CUSTOM_VIEW_PROPERTY(pointerEvents, RCTPointerEvents, RCTView)
|
||||
|
|
Loading…
Reference in New Issue