Uh oh!
There was an error while loading. Please reload this page.
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-L1245https://github.com/zertosh/invariant
I will try to fix .flowconfig and enable flow type checking for Slider props
…essibility disabled state
TO-DO
|
BartoszKlonowski
commented
Feb 4, 2022
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). |
fabOnReact
commented
Feb 4, 2022
Thanks a lot @BartoszKlonowski Thanks a lot |
BartoszKlonowski
left a comment
There was a problem hiding this comment.
Good work in general, thank you! 👍
The only remark I have is to create separate examples and it should be ready to deliver.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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#30937fixes#30947fixes#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
commented
Feb 28, 2022
Thank you, @fabriziobertoglio1987! |
…ality when disabled (react#33076) Summary: This issue fixesreact#30937fixesreact#30947fixesreact#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 react#31252) Related PR react#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: react#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]: react@17095c6 [11]: react@6ab7ab3 Reviewed By: blavalla Differential Revision: D34211793 Pulled By: ShikaSD fbshipit-source-id: e153fb48c194f5884e30beb9172e66aca7ce1a41
Summary:
This issue fixesreact/react-native#30939fixesreact/react-native#30840 (Test Case 7.1, Test Case 7.3, Test Case 7.5) .
The issue is caused by the missing prop
accessibilityStatein the Slider component.The solution consists of passing the accessibilityState to the
RCTSliderNativeComponentcomponent as previously implemented in other components (for example, Button).Relevant discussions react/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.disabledis different from the propdisabled, the propdisabledover-rides theaccessibilityState.disabledvalue.For example:
becomes:
An alternative Solution published in this branch would be:
disableddefault propfalseover-ridesaccessibilityState.disabledThis alternative solution would not respect the requirement of not having
conflicting states for accessibility and non-accessibility usersand 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
disabledandaccessibilityState={{disabled: false}}2. Slider has
disabled3. 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
disabledandaccessibilityState={{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