Skip to content

Native ARIA Roles: Shared code #37305

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

NickGerleman
Copy link
Contributor

@NickGerleman NickGerleman commented May 8, 2023

Summary:

Stack

ARIA roles in React Native are implemented on top of accessibilityRole. This is lossy because there are many more ARIA roles than accessibilityRole. This is especially true for RN on desktop where accessibilityRole was designed around accessibility APIs only available on mobile.

This series of changes aims to change this implementation to instead pass the ARIA role to native, alongside any existing accessibilityRole. This gives the platform more control in exactly how to map an ARIA role to native behavior.

As an example, this would allow mapping any ARIA role to AutomationControlType on Windows without needing to fork to add new options to accessibilityRole.

It also allows greater implementation flexibility for other platforms down the line, but for now, iOS and Android behave the same as before (though with their implementation living in native).

Diff

This syncs the Fabric representations of Roles to the current state of the world in JS, and adds usage to the view configs.

  1. Role enum for the View role prop (ARIA role)
  2. Sync enums and conversions to JS AccessibilityRole
    1. This parsing is done for TextAttributes only. View uses the string directly
    2. Add ARIA roles, and parse those to their enum form.
    3. Move enums from attributedstring primitves to accessibility primitives
  3. Add to viewconfig to allow it to be passed

Changelog: [Internal]

Differential Revision: D45431372

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner fb-exported labels May 8, 2023
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D45431372

@analysis-bot
Copy link

analysis-bot commented May 8, 2023

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,730,187 +6,019
android hermes armeabi-v7a 8,041,562 +6,386
android hermes x86 9,219,503 +6,696
android hermes x86_64 9,072,594 +6,646
android jsc arm64-v8a 9,294,931 +6,019
android jsc armeabi-v7a 8,483,732 +6,387
android jsc x86 9,355,629 +6,704
android jsc x86_64 9,612,316 +6,635

Base commit: 61335a1
Branch: main

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D45431372

NickGerleman added a commit to NickGerleman/react-native that referenced this pull request May 8, 2023
Summary:
Pull Request resolved: facebook#37305

### Stack

ARIA roles in React Native are implemented on top of `accessibilityRole`. This is lossy because there are many more ARIA roles than `accessibilityRole`. This is especially true for RN on desktop where `accessibilityRole` was designed around accessibility APIs only available on mobile.

This series of changes aims to change this implementation to instead pass the ARIA role to native, alongside any existing `accessibilityRole`. This gives the platform more control in exactly how to map an ARIA role to native behavior.

As an example, this would allow mapping any ARIA role to [`AutomationControlType`](https://learn.microsoft.com/en-us/dotnet/api/system.windows.automation.peers.automationcontroltype?view=windowsdesktop-7.0&viewFallbackFrom=dotnet-uwp-10.0) on Windows without needing to fork to add new options to `accessibilityRole`.

It also allows greater implementation flexibility for other platforms down the line, but for now, iOS and Android behave the same as before (though with their implementation living in native).

### Diff

This syncs the Fabric representations of Roles to the current state of the world in JS, and adds usage to the view configs.
1. `Role` enum for the View `role` prop (ARIA role)
2. Sync enums and conversions to JS `AccessibilityRole`
    1. This parsing is done for `TextAttributes` only. `View` uses the string directly
    2. Add ARIA roles, and parse those to their enum form.
    3. Move enums from attributedstring primitves to accessibility primitives
3. Add to viewconfig to allow it to be passed

Changelog: [Internal]

Differential Revision: D45431372

fbshipit-source-id: eac9d882cc8287741bf3c3d3ca1f1a126515c302
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D45431372

NickGerleman added a commit to NickGerleman/react-native that referenced this pull request May 8, 2023
Summary:
Pull Request resolved: facebook#37305

### Stack

ARIA roles in React Native are implemented on top of `accessibilityRole`. This is lossy because there are many more ARIA roles than `accessibilityRole`. This is especially true for RN on desktop where `accessibilityRole` was designed around accessibility APIs only available on mobile.

This series of changes aims to change this implementation to instead pass the ARIA role to native, alongside any existing `accessibilityRole`. This gives the platform more control in exactly how to map an ARIA role to native behavior.

As an example, this would allow mapping any ARIA role to [`AutomationControlType`](https://learn.microsoft.com/en-us/dotnet/api/system.windows.automation.peers.automationcontroltype?view=windowsdesktop-7.0&viewFallbackFrom=dotnet-uwp-10.0) on Windows without needing to fork to add new options to `accessibilityRole`.

It also allows greater implementation flexibility for other platforms down the line, but for now, iOS and Android behave the same as before (though with their implementation living in native).

### Diff

This syncs the Fabric representations of Roles to the current state of the world in JS, and adds usage to the view configs.
1. `Role` enum for the View `role` prop (ARIA role)
2. Sync enums and conversions to JS `AccessibilityRole`
    1. This parsing is done for `TextAttributes` only. `View` uses the string directly
    2. Add ARIA roles, and parse those to their enum form.
    3. Move enums from attributedstring primitves to accessibility primitives
3. Add to viewconfig to allow it to be passed

Changelog: [Internal]

Differential Revision: D45431372

fbshipit-source-id: 21a5df082c3b0a202994f150e9eafe4619b4da7b
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D45431372

NickGerleman added a commit to NickGerleman/react-native that referenced this pull request May 13, 2023
Summary:
Pull Request resolved: facebook#37305

### Stack

ARIA roles in React Native are implemented on top of `accessibilityRole`. This is lossy because there are many more ARIA roles than `accessibilityRole`. This is especially true for RN on desktop where `accessibilityRole` was designed around accessibility APIs only available on mobile.

This series of changes aims to change this implementation to instead pass the ARIA role to native, alongside any existing `accessibilityRole`. This gives the platform more control in exactly how to map an ARIA role to native behavior.

As an example, this would allow mapping any ARIA role to [`AutomationControlType`](https://learn.microsoft.com/en-us/dotnet/api/system.windows.automation.peers.automationcontroltype?view=windowsdesktop-7.0&viewFallbackFrom=dotnet-uwp-10.0) on Windows without needing to fork to add new options to `accessibilityRole`.

It also allows greater implementation flexibility for other platforms down the line, but for now, iOS and Android behave the same as before (though with their implementation living in native).

### Diff

This syncs the Fabric representations of Roles to the current state of the world in JS, and adds usage to the view configs.
1. `Role` enum for the View `role` prop (ARIA role)
2. Sync enums and conversions to JS `AccessibilityRole`
    1. This parsing is done for `TextAttributes` only. `View` uses the string directly
    2. Add ARIA roles, and parse those to their enum form.
    3. Move enums from attributedstring primitves to accessibility primitives
3. Add to viewconfig to allow it to be passed

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D45431372

fbshipit-source-id: 15783e6521e2b6d8a10eb2fceb514bfcb5b26f27
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D45431372

Summary:
Pull Request resolved: facebook#37305

### Stack

ARIA roles in React Native are implemented on top of `accessibilityRole`. This is lossy because there are many more ARIA roles than `accessibilityRole`. This is especially true for RN on desktop where `accessibilityRole` was designed around accessibility APIs only available on mobile.

This series of changes aims to change this implementation to instead pass the ARIA role to native, alongside any existing `accessibilityRole`. This gives the platform more control in exactly how to map an ARIA role to native behavior.

As an example, this would allow mapping any ARIA role to [`AutomationControlType`](https://learn.microsoft.com/en-us/dotnet/api/system.windows.automation.peers.automationcontroltype?view=windowsdesktop-7.0&viewFallbackFrom=dotnet-uwp-10.0) on Windows without needing to fork to add new options to `accessibilityRole`.

It also allows greater implementation flexibility for other platforms down the line, but for now, iOS and Android behave the same as before (though with their implementation living in native).

### Diff

This syncs the Fabric representations of Roles to the current state of the world in JS, and adds usage to the view configs.
1. `Role` enum for the View `role` prop (ARIA role)
2. Sync enums and conversions to JS `AccessibilityRole`
    1. This parsing is done for `TextAttributes` only. `View` uses the string directly
    2. Add ARIA roles, and parse those to their enum form.
    3. Move enums from attributedstring primitves to accessibility primitives
3. Add to viewconfig to allow it to be passed

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D45431372

fbshipit-source-id: f0f02101fa573da475c0e7b084172557a8780bd8
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D45431372

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label May 13, 2023
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 9db5fa2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants