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

[Accessibility] Fix Image does not announce "disabled" #31252

Closed
wants to merge 11 commits into from

Conversation

fabOnReact
Copy link
Contributor

@fabOnReact fabOnReact commented Mar 26, 2021

Summary

This issue fixes #30935 fixes #30936 screenreader does not announce Image disabled accessibilityState.

As stated in AOSP View.java, the framework will handle routine focus movement, views indicate their willingness to take focus through the isFocusable method https://bit.ly/3dCnyHb

* <p>The framework will handle routine focus movement in response to user input. This includes
* changing the focus as views are removed or hidden, or as new views become available. Views
* indicate their willingness to take focus through the {@link #isFocusable} method. To change
* whether a view can take focus, call {@link #setFocusable(boolean)}.

The property is updated through its shadow node ReactImageManager method setAccessible https://bit.ly/3dDuK5L

 * <p>Instances of this class receive property updates from JS via @{link UIManagerModule}.
 * Subclasses may use {@link #updateShadowNode} to persist some of the updated fields in the node
 * instance that corresponds to a particular view type.

Changelog

[Android] [Fixed] - adding setAccessible to ReactImageManager to allow screenreader announce Image accessibilityState of "disabled"

Test Plan

CLICK TO OPEN TESTS RESULTS

Enable audio to hear the screenreader

TEST SCENARIO

  • The user moves the screenreader focus to an image and the screenreader reads the Image accessibilityLabel "plain network image"

RESULT

  • The screenreader announces the accessibilityState disabled after reading the Image accessibilityLabel "plain network image"
<Image
  accessible={true}
  accessibilityLabel="plain network image"
  accessibilityState={{disabled: true}}
  source={fullImage}
  style={styles.base}
/>
2021-03-26.18-27-36.mp4

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 26, 2021
@fabOnReact
Copy link
Contributor Author

fabOnReact commented Mar 26, 2021

@analysis-bot
Copy link

analysis-bot commented Mar 26, 2021

Platform Engine Arch Size (bytes) Diff
ios - universal n/a --

Base commit: da899c0

@amarlette
Copy link

amarlette commented Mar 26, 2021

Thank you for working on this issue @fabriziobertoglio1987! Excited to see your finished PR.

Got you on the project board and will assign a reviewer when you are out of drafts.

@fabOnReact fabOnReact marked this pull request as ready for review April 6, 2021 16:33
@lunaleaps
Copy link
Contributor

lunaleaps commented Apr 22, 2021

@fabriziobertoglio1987 is this ready for review? Ah sorry looks like it is, I'll move it to the right column then

@fabOnReact
Copy link
Contributor Author

sorry @lunaleaps, I did set this as ready for review. Currently I'm away from office, but I will be doing opensource again in 1-2 weeks. Thanks a lot. I wish you a good day

@kacieb
Copy link
Contributor

kacieb commented Apr 23, 2021

cc @blavalla for Android review!

@@ -929,4 +932,18 @@ exports.examples = [
return <EnabledExamples />;
},
},
{
title: 'Check if these properties are enabled',
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: It would be good to specify what properties we're testing here - in this case it's image focusability and disabled state.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kacieb thanks for the code review. I experienced some issues with flipper after the last rebase and I published pr #31468 which includes solution to the runtime in the rn-tester app. I added the changes you required and tested them using the fix #31468. The functionality works like before. Thanks a lot 🙏

Copy link
Contributor

@blavalla blavalla left a comment

Choose a reason for hiding this comment

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

Android code looks good to me!

@@ -30,6 +30,9 @@ const checkImageSource = require('./check.png');
const uncheckImageSource = require('./uncheck.png');
const mixedCheckboxImageSource = require('./mixed.png');
const {createRef} = require('react');
const fullImage = {
uri: 'https://www.facebook.com/ads/pics/successstories.png',
Copy link
Contributor

@lunaleaps lunaleaps Apr 26, 2021

Choose a reason for hiding this comment

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

Do you think we should reference a local asset here instead of fetching over network? I know there are some assets under js/assets/..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks a lot for the code review @lunaleaps. I added the changes required. More info in comment #31252 (comment) 🙏

@analysis-bot
Copy link

analysis-bot commented Apr 27, 2021

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,864,454 -122,281
android hermes armeabi-v7a 8,386,258 -107,725
android hermes x86 9,321,886 -117,136
android hermes x86_64 9,264,852 -115,931
android jsc arm64-v8a 10,593,478 -11,656
android jsc armeabi-v7a 10,098,377 -7,030
android jsc x86 10,612,415 -11,729
android jsc x86_64 11,195,638 -12,174

Base commit: da899c0

@@ -48,8 +48,8 @@ const styles = StyleSheet.create({
borderStyle: 'solid',
},
image: {
width: 20,
height: 20,
width: 120,
Copy link
Contributor

@lunaleaps lunaleaps May 3, 2021

Choose a reason for hiding this comment

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

@fabriziobertoglio1987 Would this break other accessibility examples that use styles.image? Could create a separate styles.disabledImage? Did you want me to add during import? Otherwise I think this looks good!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lunaleaps thanks a lot for the codereview.. sorry for this. I just updated the code with commit f5e4a16 I remain available 🙏

Copy link
Contributor

@lunaleaps lunaleaps left a comment

Choose a reason for hiding this comment

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

Great! Thank you for your help! Importing this now :)

@facebook-github-bot
Copy link
Contributor

@lunaleaps has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@lunaleaps merged this pull request in 333b46c.

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label May 4, 2021
@amarlette
Copy link

Thank you @fabriziobertoglio1987 for another great contribution to a more accessible React Native! 😄

I'll highlight you with the same info from your other PR.

@fabOnReact
Copy link
Contributor Author

@lunaleaps thanks a lot for merging this pr. I will look for my next issues in the Accessibility Project 🙏
@amarlette thanks a lot for the mention 🙏

facebook-github-bot pushed a commit that referenced this pull request Feb 15, 2022
…ality when disabled (#33076)

Summary:
This issue fixes #30937 fixes #30947 fixes #30840 ([Test Case 7.1][7.1], [Test Case 7.3][7.3], [Test Case 7.5][7.5]) .
The issue is caused by:

1) The missing javascript logic on the `accessibilityState` in the Text component fabOnReact@6ab7ab3 (as previously implemented in [Button][20]).
2) The missing setter for prop `accessible` in `ReactTextAnchorViewManager` fabOnReact@17095c6 (More information in previous PR #31252)

Related PR #33070 PR callstack/react-native-slider#354

[20]: https://github.com/facebook/react-native/pull/31001/files#diff-4f225d043edf4cf5b8288285b6a957e2187fc0242f240bde396e41c4c25e4124R281-R289

## Changelog

[Android] [Fixed] - Text Component does not announce disabled and disables click functionality when disabled

Pull Request resolved: #33076

Test Plan:
[1]. Text has `disabled` and `accessibilityState={{disabled: false}}` ([link][1])
[2]. Text has `disabled` ([link][2])
[3]. Text has `accessibilityState={{disabled: true}}` ([link][3])
[4]. Text has `accessibilityState={{disabled:false}}` ([link][4])
[5]. Text has `disabled={false}`  and `accessibilityState={{disabled:true}}` ([link][5])
[6]. Text has `accessibilityState={{disabled:true}}` and method `setAccessible` in `ReactTextAnchorViewManager` (tested on commit [b4cd8][10]) ([link][6])
7. Test Cases on the main branch
[7.1]. Text has `disabled` and `accessibilityState={{disabled: false}}` ([link][7.1])
[7.3] Text has `accessibilityState={{disabled: true}}` ([link][7.3])
[7.5] Text has `disabled={false}`  and `accessibilityState={{disabled:true}}` ([link][7.5])
[7.6] Text has `onPress callback` and `accessibilityState={{disabled: true}}` ([link][7.6])
[7.7] Text has `accessibilityState={{disabled:true}}` and no method `setAccessible` in `ReactTextAnchorViewManager` (tested on commit [c4f98dd][11]) ([link][7.7])

[1]: fabOnReact/react-native-notes#1 (comment)
[2]: fabOnReact/react-native-notes#1 (comment)
[3]: fabOnReact/react-native-notes#1 (comment)
[4]: fabOnReact/react-native-notes#1 (comment)
[5]: fabOnReact/react-native-notes#1 (comment)
[6]: fabOnReact/react-native-notes#1 (comment)
[7.1]: fabOnReact/react-native-notes#1 (comment)
[7.3]: fabOnReact/react-native-notes#1 (comment)
[7.5]: fabOnReact/react-native-notes#1 (comment)
[7.6]: fabOnReact/react-native-notes#1 (comment)
[7.7]: fabOnReact/react-native-notes#1 (comment)

[10]: 17095c6
[11]: 6ab7ab3

Reviewed By: blavalla

Differential Revision: D34211793

Pulled By: ShikaSD

fbshipit-source-id: e153fb48c194f5884e30beb9172e66aca7ce1a41
Saadnajmi pushed a commit to Saadnajmi/react-native-macos that referenced this pull request Jan 15, 2023
…ality when disabled (facebook#33076)

Summary:
This issue fixes facebook#30937 fixes facebook#30947 fixes facebook#30840 ([Test Case 7.1][7.1], [Test Case 7.3][7.3], [Test Case 7.5][7.5]) .
The issue is caused by:

1) The missing javascript logic on the `accessibilityState` in the Text component fabOnReact@6ab7ab3 (as previously implemented in [Button][20]).
2) The missing setter for prop `accessible` in `ReactTextAnchorViewManager` fabOnReact@17095c6 (More information in previous PR facebook#31252)

Related PR facebook#33070 PR callstack/react-native-slider#354

[20]: https://github.com/facebook/react-native/pull/31001/files#diff-4f225d043edf4cf5b8288285b6a957e2187fc0242f240bde396e41c4c25e4124R281-R289

[Android] [Fixed] - Text Component does not announce disabled and disables click functionality when disabled

Pull Request resolved: facebook#33076

Test Plan:
[1]. Text has `disabled` and `accessibilityState={{disabled: false}}` ([link][1])
[2]. Text has `disabled` ([link][2])
[3]. Text has `accessibilityState={{disabled: true}}` ([link][3])
[4]. Text has `accessibilityState={{disabled:false}}` ([link][4])
[5]. Text has `disabled={false}`  and `accessibilityState={{disabled:true}}` ([link][5])
[6]. Text has `accessibilityState={{disabled:true}}` and method `setAccessible` in `ReactTextAnchorViewManager` (tested on commit [b4cd8][10]) ([link][6])
7. Test Cases on the main branch
[7.1]. Text has `disabled` and `accessibilityState={{disabled: false}}` ([link][7.1])
[7.3] Text has `accessibilityState={{disabled: true}}` ([link][7.3])
[7.5] Text has `disabled={false}`  and `accessibilityState={{disabled:true}}` ([link][7.5])
[7.6] Text has `onPress callback` and `accessibilityState={{disabled: true}}` ([link][7.6])
[7.7] Text has `accessibilityState={{disabled:true}}` and no method `setAccessible` in `ReactTextAnchorViewManager` (tested on commit [c4f98dd][11]) ([link][7.7])

[1]: fabOnReact/react-native-notes#1 (comment)
[2]: fabOnReact/react-native-notes#1 (comment)
[3]: fabOnReact/react-native-notes#1 (comment)
[4]: fabOnReact/react-native-notes#1 (comment)
[5]: fabOnReact/react-native-notes#1 (comment)
[6]: fabOnReact/react-native-notes#1 (comment)
[7.1]: fabOnReact/react-native-notes#1 (comment)
[7.3]: fabOnReact/react-native-notes#1 (comment)
[7.5]: fabOnReact/react-native-notes#1 (comment)
[7.6]: fabOnReact/react-native-notes#1 (comment)
[7.7]: fabOnReact/react-native-notes#1 (comment)

[10]: facebook@17095c6
[11]: facebook@6ab7ab3

Reviewed By: blavalla

Differential Revision: D34211793

Pulled By: ShikaSD

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

Successfully merging this pull request may close these issues.

ImageBackground does not announce "disabled" Image does not announce "disabled"
7 participants