Skip to content

Commit

Permalink
Add UIAccessibilityTraitUpdatesFrequently to progressBar role
Browse files Browse the repository at this point in the history
Summary:
Changelog:
Add UIAccessibilityTraitUpdatesFrequently when the AccessibilityRole is set to progressBar. This trait tells the accessibility system where content may change with every percentage point, but without annoying the user with constant announcements.

Reviewed By: ikenwoo

Differential Revision: D30510587

fbshipit-source-id: e75690a2a56ce42476dc999383cf58c0811fcbdf
  • Loading branch information
jimmy623 authored and facebook-github-bot committed Aug 25, 2021
1 parent ee3e71f commit 1a42bd6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions React/Views/RCTViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ @implementation RCTConvert (UIAccessibilityTraits)
@"menu" : @(UIAccessibilityTraitNone),
@"menubar" : @(UIAccessibilityTraitNone),
@"menuitem" : @(UIAccessibilityTraitNone),
@"progressbar" : @(UIAccessibilityTraitNone),
@"progressbar" : @(UIAccessibilityTraitUpdatesFrequently),
@"radio" : @(UIAccessibilityTraitNone),
@"radiogroup" : @(UIAccessibilityTraitNone),
@"scrollbar" : @(UIAccessibilityTraitNone),
Expand Down Expand Up @@ -172,7 +172,8 @@ - (RCTShadowView *)shadowView
const UIAccessibilityTraits AccessibilityRolesMask = UIAccessibilityTraitNone | UIAccessibilityTraitButton |
UIAccessibilityTraitLink | UIAccessibilityTraitSearchField | UIAccessibilityTraitImage |
UIAccessibilityTraitKeyboardKey | UIAccessibilityTraitStaticText | UIAccessibilityTraitAdjustable |
UIAccessibilityTraitHeader | UIAccessibilityTraitSummaryElement | SwitchAccessibilityTrait;
UIAccessibilityTraitHeader | UIAccessibilityTraitSummaryElement | UIAccessibilityTraitTabBar |
UIAccessibilityTraitUpdatesFrequently | SwitchAccessibilityTrait;
view.reactAccessibilityElement.accessibilityTraits =
view.reactAccessibilityElement.accessibilityTraits & ~AccessibilityRolesMask;
UIAccessibilityTraits newTraits = json ? [RCTConvert UIAccessibilityTraits:json] : defaultView.accessibilityTraits;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ inline void fromString(const std::string &string, AccessibilityTraits &result) {
result = AccessibilityTraits::TabBar;
return;
}
if (string == "progressbar") {
result = AccessibilityTraits::UpdatesFrequently;
return;
}
result = AccessibilityTraits::None;
}

Expand Down

0 comments on commit 1a42bd6

Please sign in to comment.