Skip to content

Commit 033200f

Browse files
committed
Map role="slider" to the adjustable accessibility trait on iOS
`role="slider"` resolves to no accessibility traits on iOS, so VoiceOver does not treat the view as adjustable, while `accessibilityRole="adjustable"` does. Before the ARIA roles moved to native, the JS mapping turned `role: 'slider'` into `accessibilityRole: 'adjustable'`. Add `slider` to the `adjustable` case of the traits `fromString`, the same way `img`/`image` and `heading`/`header` share a case.
1 parent 7fc911a commit 033200f

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎packages/react-native/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ inline void fromString(const std::string &string, AccessibilityTraits &result)
7171
result = AccessibilityTraits::StartsMediaSession;
7272
return;
7373
}
74-
if (string == "adjustable") {
74+
if (string == "adjustable" || string == "slider") {
7575
result = AccessibilityTraits::Adjustable;
7676
return;
7777
}

‎packages/react-native/ReactCommon/react/renderer/components/view/tests/AccessibilityPropsTest.cpp‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ TEST(AccessibilityPropsTest, derives_traits_from_role) {
4444
EXPECT_TRUE(hasTrait(props.accessibilityTraits, AccessibilityTraits::Button));
4545
}
4646

47+
TEST(AccessibilityPropsTest, derives_adjustable_trait_from_slider_role) {
48+
auto props = parse(folly::dynamic::object("role", "slider"));
49+
50+
EXPECT_TRUE(
51+
hasTrait(props.accessibilityTraits, AccessibilityTraits::Adjustable));
52+
}
53+
4754
TEST(AccessibilityPropsTest, derives_traits_from_accessibility_role) {
4855
auto props = parse(folly::dynamic::object("accessibilityRole", "image"));
4956

0 commit comments

Comments
 (0)