-
Notifications
You must be signed in to change notification settings - Fork 267
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
Fix: Conflicting states for accessibility and non-accessibility users #354
Conversation
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
I will try to fix .flowconfig and enable flow type checking for Slider props
…essibility disabled state
TO-DO
|
Thank you, @fabriziobertoglio1987! 👍 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). |
Thanks a lot @BartoszKlonowski Thanks a lot |
There was a problem hiding this 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.
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.
…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)
Thank you, @fabriziobertoglio1987! |
…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
… (#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>
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:
accessibilityState.disabled
is different from the propdisabled
, the propdisabled
over-rides theaccessibilityState.disabled
value.For example:
becomes:
An alternative Solution published in this branch would be:
disabled
default propfalse
over-ridesaccessibilityState.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:
would become (as the deafult is
disabled={false}
)ADDITIONAL NOTES
<Slider disabled={"true"} />
triggers a wrong type warning with typescript.<Slider disabled={"true"} />
does not trigger a wrong type warning with flow.js.Test Plan:
Android:
1. Slider has
disabled
andaccessibilityState={{disabled: false}}
2. Slider has
disabled
3. Slider has
accessibilityState={{disabled: true}}
4. Slider has
accessibilityState={{disabled:false}}
5. Slider has
disabled={false}
andaccessibilityState={{disabled:true}}
7. Test Cases on the main branch
7.1. Slider has
disabled
andaccessibilityState={{disabled: false}}
7.3 Slider has
accessibilityState={{disabled: true}}
7.5 Slider has
disabled={false}
andaccessibilityState={{disabled:true}}
7.6 Wrong prop type
disabled="not a boolean value"
with typescript7.7 Wrong prop type
disabled="not a boolean value"
with flow on the master branch