From 05f99a7d252cc908855e96aecbb1d40ae76c846a Mon Sep 17 00:00:00 2001 From: Jelte Homminga Date: Mon, 26 Oct 2026 07:19:05 -0700 Subject: [PATCH] Map role="slider" to the adjustable accessibility trait on iOS (#59463) Summary: Hi, I'm a React Native developer. Thanks for the recent iOS accessibility work. On iOS, `role="slider"` ends up with no accessibility traits, so VoiceOver doesn't treat the view as adjustable. `accessibilityRole="adjustable"` on the same view works. The traits come from `fromString(const std::string &, AccessibilityTraits &)` in `accessibilityPropsConversions.h`, which has an `"adjustable"` case but no `"slider"` case. Before the ARIA roles moved to native in https://github.com/react/react-native/issues/37309, the JS mapping turned `role: 'slider'` into `accessibilityRole: 'adjustable'`, so this used to work. The native table maps `slider` to no trait instead. This adds `slider` to the `adjustable` case, the same way `img`/`image` and `heading`/`header` share a case. Android doesn't read `accessibilityTraits`, so only iOS changes. It only touches `slider`. The other roles listed in https://github.com/react/react-native/issues/50123 stay as they are, since the comment above `RCTViewIsInteractiveAccessibilityElement` says some of them carry no trait on purpose. I also left the legacy `RCTViewManager.m` table alone, which maps `slider` to `UIAccessibilityTraitNone` as well. Happy to change that one too if it's still wanted. Part of https://github.com/react/react-native/issues/50123. ## Changelog: [IOS] [FIXED] - `role="slider"` now gets the adjustable accessibility trait, like `accessibilityRole="adjustable"` Pull Request resolved: https://github.com/react/react-native/pull/59463 Test Plan: RNTester on an iPhone 18 Pro simulator (iOS 27.0), with the Playground rendering: ```tsx ``` The simulator's accessibility tree for both views: ``` main Role slider AXGroup traits: none AccessibilityRole adjustable AXAdjustable traits: adjustable this PR Role slider AXAdjustable traits: adjustable AccessibilityRole adjustable AXAdjustable traits: adjustable ``` - Added `derives_adjustable_trait_from_slider_role` to `AccessibilityPropsTest.cpp`, next to `derives_traits_from_role`. I couldn't run it, because I didn't find a way to run the ReactCommon gtests from the open-source checkout. - `node scripts/clang-format.js --check` passes on both files. - Not checked: the legacy architecture. Reviewed By: christophpurrer Differential Revision: D127482367 Pulled By: Abbondanzo fbshipit-source-id: bd315b64e1492c92d7a2b20831bab2dd636d2360 --- .../components/view/accessibilityPropsConversions.h | 2 +- .../components/view/tests/AccessibilityPropsTest.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h b/packages/react-native/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h index bcb3d915c09..4af4d8fc924 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h +++ b/packages/react-native/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h @@ -71,7 +71,7 @@ inline void fromString(const std::string &string, AccessibilityTraits &result) result = AccessibilityTraits::StartsMediaSession; return; } - if (string == "adjustable") { + if (string == "adjustable" || string == "slider") { result = AccessibilityTraits::Adjustable; return; } diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/tests/AccessibilityPropsTest.cpp b/packages/react-native/ReactCommon/react/renderer/components/view/tests/AccessibilityPropsTest.cpp index 38c1d82b969..b66d498b85d 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/tests/AccessibilityPropsTest.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/view/tests/AccessibilityPropsTest.cpp @@ -44,6 +44,13 @@ TEST(AccessibilityPropsTest, derives_traits_from_role) { EXPECT_TRUE(hasTrait(props.accessibilityTraits, AccessibilityTraits::Button)); } +TEST(AccessibilityPropsTest, derives_adjustable_trait_from_slider_role) { + auto props = parse(folly::dynamic::object("role", "slider")); + + EXPECT_TRUE( + hasTrait(props.accessibilityTraits, AccessibilityTraits::Adjustable)); +} + TEST(AccessibilityPropsTest, derives_traits_from_accessibility_role) { auto props = parse(folly::dynamic::object("accessibilityRole", "image"));