Skip to content
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

Enabling AccessibilityInfo.setAccessibilityFocus for MacOS #450

Merged
merged 11 commits into from
Jun 16, 2020

Conversation

graytmatterMS
Copy link

@graytmatterMS graytmatterMS commented Jun 12, 2020

Please select one of the following

  • I am removing an existing difference between facebook/react-native and microsoft/react-native-macos 👍
  • I am cherry-picking a change from Facebook's react-native into microsoft/react-native-macos 👍
  • I am making a fix / change for the macOS implementation of react-native
  • I am making a change required for Microsoft usage of react-native

Summary

When the MacOS fork was made all the AccessibilityInfo functionality was stubbed out because the iOS Accessibility APIs are different from the MacOS APIs. I've filled back out the functionality for setAccessibilityFocus.

Changelog

[MacOS] [Added] - Implemented AccessibilityInfo.setAccessibilityFocus

Test Plan

  1. Run RNTester
  2. Go to the accessibility page
  3. Scroll to Set Accessibility Focus (the last entry)
  4. Toggle VoiceOver in settings.
  5. Move VoiceOver Focus to "Set Accessibility Focus"
  6. Hit [Space]
  • You should see the focus being moved to "Move focus here on button press".

Screen Shot 2020-06-12 at 10 25 40
Screen Shot 2020-06-12 at 10 26 12

Microsoft Reviewers: Open in CodeFlow

@graytmatterMS graytmatterMS requested a review from tom-un as a code owner June 12, 2020 17:43
Copy link

@analysis-bot analysis-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code analysis results:

  • eslint found some issues. Run yarn lint --fix to automatically fix problems.

@@ -54,6 +54,14 @@ - (void)dealloc
callback(@[ @(isVoiceOverEnabled) ]);
}

RCT_EXPORT_METHOD(setAccessibilityFocus:(nonnull NSNumber *)reactTag)
{
dispatch_async(dispatch_get_main_queue(), ^{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use RCTExecuteOnMainQueue here?

Suggested change
dispatch_async(dispatch_get_main_queue(), ^{
RCTExecuteOnMainQueue(^{

(You might have to also add #import "RCTUtils.h" on top.)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is consistent with the iOS implementation that just calls dispatch_async on main queue. The RCTExecuteOnMainQueue does the same thing, but checks if already on the main queue and if so just calls the block. In this case it will always be called on the JS thread.

@@ -570,6 +570,26 @@ class AnnounceForAccessibility extends React.Component<{}> {
}
}

class SetAccessibilityFocus extends React.Component<{}> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you create a PR upstream for this?

@tom-un tom-un merged commit 33c5b49 into microsoft:master Jun 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants