Repository navigation
Conversation
…react#59378) Summary: Part of react#59377. `Touchable*` build their host view props from a fixed list, and some props they accept in their types never reach it: - `role`: none of `TouchableOpacity`, `TouchableHighlight`, `TouchableNativeFeedback`, `TouchableWithoutFeedback` passes it, so `<TouchableOpacity role="button">` has no role while `accessibilityRole="button"` works. - `TouchableWithoutFeedback` drops `aria-label`. - `TouchableHighlight` drops `aria-busy`, `aria-checked`, `aria-disabled`, `aria-expanded` and `aria-selected`; the other three already map them. This change passes `role` from all four, maps `aria-label` in `TouchableWithoutFeedback` (it wins over `accessibilityLabel`, as in `View`, and the child keeps its own label when neither is set) and maps the state props in `TouchableHighlight` the same way `TouchableOpacity` does. `aria-labelledby` is left to react#58173. The shared `rolePropSuite` now also runs for `TouchableNativeFeedback` and `TouchableWithoutFeedback`; before, it ran only for `Text`. It cannot run for `TouchableOpacity` and `TouchableHighlight`: Fantom reads the debug props of a view, and `AccessibilityProps::getDebugProps` does not include `role`, so `role` on their host view is checked on a device instead (pairs G / H of the reproducer). ## Changelog: [GENERAL] [FIXED] - `role` on `Touchable*`, `aria-label` on `TouchableWithoutFeedback` and `aria-*` state props on `TouchableHighlight` reach the native view Pull Request resolved: react#59378 Test Plan: - `yarn fantom packages/react-native/Libraries/Components/Touchable`: 4 suites, 272 tests passed. (Locally with `CXXFLAGS=-Wno-deprecated-literal-operator`: Xcode 27.1 clang rejects the `operator "" _json` syntax of the bundled nlohmann_json 3.11.2 under `-Werror`; unrelated to this change.) - `yarn flow-check`: no errors. `yarn eslint` on the changed files: no warnings. - On a device: the reproducer https://github.com/faciledictu/rn-aria-props-repro, pairs G–L. Before: on Android 17, G is `android.view.ViewGroup`, I's `content-desc` is the child's "×", K has no `checked`; on iOS 27, G has no Button trait, I's label is "×", K's value has no "checked". After, on iOS 27: G has the Button trait, I's label is "Close I", K's value is "checkbox, checked". After, on Android 17: G is `android.widget.Button`, I's `content-desc` is "Close I", K is `checkable="true" checked="true"`. Each matches its `accessibility*` control (H, J, L). - Snapshot refresh (2026-11-05): `js1 test --runInBand --watch=false --runTestsByPath` on `MobileHomeBAMFilterBar`, `MobileHomeBAMUrgencyPillter`, `TWTabPager`, `OCReferralsSurface` and `ActivityLogClearButton`: 5 suites, 25 tests and 17 snapshots passed after regenerating 14 snapshots. `TouchableHighlight.js` is unchanged from the original imported version. - `arc lint -a`: no lint issues. Differential Revision: D129326374 Pulled By: javache
Summary: Use the supplied `accessibilityState` as the default and only build a new state object when an ARIA state prop overrides it. This avoids reconstructing a sparse state object with extra undefined fields when no ARIA override is supplied. ARIA precedence and the explicit `disabled` override are unchanged. Refresh the affected snapshots and assert that the button keeps its empty accessibility state. Changelog: [Internal] Differential Revision: D129885143
|
@javache has exported this pull request. If you are a Meta employee, you can view the originating Diff in D129885143. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Use the supplied
accessibilityStateas the default and only build a new state object when an ARIA state prop overrides it. This avoids reconstructing a sparse state object with extra undefined fields when no ARIA override is supplied. ARIA precedence and the explicitdisabledoverride are unchanged.Refresh the affected snapshots and assert that the button keeps its empty accessibility state.
Changelog: [Internal]
Differential Revision: D129885143