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

Fix: Conflicting states for accessibility and non-accessibility users #354

Conversation

fabOnReact
Copy link
Contributor

@fabOnReact fabOnReact commented Feb 1, 2022

Summary:

This issue fixes facebook/react-native#30939 fixes facebook/react-native#30840 (Test Case 7.1, Test Case 7.3, Test Case 7.5) .
The issue is caused by the missing prop accessibilityState in the Slider component.

The solution consists of passing the accessibilityState to the RCTSliderNativeComponent component as previously implemented in other components (for example, Button).

Relevant discussions facebook/react-native#30840 (comment) and https://github.com/facebook/react-native/pull/31001/files#r578827409.

The solution proposed in this pull request consists of:

  1. removing the disabled default prop (related discussions fabOnReact@fc9f0c4 and fabOnReact/react-native@afb7fc2).
  2. If the value of prop accessibilityState.disabled is different from the prop disabled, the prop disabled over-rides the accessibilityState.disabled value.

For example:

<Slider disabled={true} accessibilityState={{disabled: false}} />

becomes:

<Slider disabled={true} accessibilityState={{disabled: true}} />
  1. Remove the existing Android java logic

An alternative Solution published in this branch would be:

  • not removing the default prop for disabled (false).
  • disabled default prop false over-rides accessibilityState.disabled

This alternative solution would not respect the requirement of not having conflicting states for accessibility and non-accessibility users and the approach adopted in react-native Components (for ex. Button).

For example:

<Slider accessibilityState={{disabled: true}} />

would become (as the deafult is disabled={false})

<Slider accessibilityState={{disabled: false}} />

ADDITIONAL NOTES

Test Plan:

Android:

1. Slider has disabled and accessibilityState={{disabled: false}}
2. Slider has disabled
3. Slider has accessibilityState={{disabled: true}}
4. Slider has accessibilityState={{disabled:false}}
5. Slider has disabled={false} and accessibilityState={{disabled:true}}
7. Test Cases on the main branch
7.1. Slider has disabled and accessibilityState={{disabled: false}}
7.3 Slider has accessibilityState={{disabled: true}}
7.5 Slider has disabled={false} and accessibilityState={{disabled:true}}
7.6 Wrong prop type disabled="not a boolean value" with typescript
7.7 Wrong prop type disabled="not a boolean value" with flow on the master branch

@fabOnReact
Copy link
Contributor Author

fabOnReact commented Feb 1, 2022

TO-DO

  • Test Android
  • Test iOS

@BartoszKlonowski
Copy link
Member

Thank you, @fabriziobertoglio1987! 👍
Looking forward to have this improvement - can you let me know if you plan to continue (making it ready to be reviewed)?

Also: Let me know if you need help with testing it on iOS (of course it's all Java implementation, but we will need to check if changing the JS layer affected other platforms).

@fabOnReact
Copy link
Contributor Author

Thanks a lot @BartoszKlonowski
I plan to continue. I will test iOS and then move this pull request to Ready to Review.

Thanks a lot
I wish you a good weekend 🙏

Copy link
Member

@BartoszKlonowski BartoszKlonowski left a comment

Choose a reason for hiding this comment

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

Good work in general, thank you! 👍
The only remark I have is to create separate examples and it should be ready to deliver.

src/js/Slider.js Show resolved Hide resolved
example/SliderExample.js Outdated Show resolved Hide resolved
There's already a test, where disabled={true} is checked against
accessibilityState={{disabled: false}},
but to double check all the combinations this commit adds new test
that acts as the inverted scenario to make sure that conflicts are
avoided both directions.
facebook-github-bot pushed a commit to facebook/react-native 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
It would be better to show that both these properties can be used separately without fear of another.
callstack#354 (comment)
@BartoszKlonowski
Copy link
Member

Thank you, @fabriziobertoglio1987!

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
grudev32 pushed a commit to grudev32/react-native-slider-fork that referenced this pull request Aug 8, 2024
… (#354)

* adding accessibilityState.disabled prop to Slider.js

* removing java logic to trigger accessibility disabled announcement

* jest tests accessiblityState.disabled and disabled prop

* update jest snapshots

* adding invariant check on disabled prop type

Flow check on master seems to not work
fabOnReact/react-native-notes#2 (comment)

As an alternative I implemented an invariant check.
https://github.com/fabriziobertoglio1987/react-native/blob/76a2cf3569571b943b4bcc6867e069338ff88f1f/Libraries/Lists/VirtualizedList.js#L1240-L1245
https://github.com/zertosh/invariant

* adding Slider disabled example

* trigger invariant error when props.disabled is null

* remove check on prop type commit 16d321b

I will try to fix .flowconfig and enable flow type checking for Slider props

* improve test cases descriptions

* add LogBox (console.warn) message to notify developer conflicting accessibility disabled state

* update LogBox warning text

* remove LogBox warning

* jest fix obsolete snapshots

* Add test for reverted disabled/enabled case

There's already a test, where disabled={true} is checked against
accessibilityState={{disabled: false}},
but to double check all the combinations this commit adds new test
that acts as the inverted scenario to make sure that conflicts are
avoided both directions.

* avoid conflicting disabled states

It would be better to show that both these properties can be used separately without fear of another.
callstack/react-native-slider#354 (comment)

Co-authored-by: BartoszKlonowski <Bartosz.Klonowski@callstack.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants