-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix/30842 - Add accessibilityState prop in slider (#31145)
Summary: Accessibility service does not announce "selected" on accessibilityState = {selected: true} of the Button Component. Issue link - #30956 ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://github.com/facebook/react-native/wiki/Changelog --> [General] [Added] - Add accessibilityState prop to Slider component Pull Request resolved: #31145 Test Plan: Verified accessibility states are read by voiceover and talkback. Some state values aren't handled by iOS and have been identified. Added snapshot tests to test accessibilityState.disabled = disabled values `js1 test Slider-test` Reviewed By: yungsters Differential Revision: D28337723 Pulled By: lunaleaps fbshipit-source-id: 72a54d8d9dcf1fafb9785c81da99f32a21f3df00
- Loading branch information
1 parent
0aa1aa6
commit 35dd861
Showing
4 changed files
with
210 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
* @format | ||
*/ | ||
|
||
import * as React from 'react'; | ||
import ReactTestRenderer from 'react-test-renderer'; | ||
import Slider from '../Slider/Slider'; | ||
|
||
describe('<Slider />', () => { | ||
it('should render as expected', () => { | ||
expect(ReactTestRenderer.create(<Slider />)).toMatchSnapshot(); | ||
}); | ||
|
||
it('should set disabled as false', () => { | ||
// Slider component should set disabled prop as false by default | ||
expect(ReactTestRenderer.create(<Slider />)).toMatchSnapshot(); | ||
expect( | ||
ReactTestRenderer.create( | ||
<Slider accessibilityState={{disabled: false}} />, | ||
), | ||
).toMatchSnapshot(); | ||
}); | ||
it('should set disabled as true', () => { | ||
expect(ReactTestRenderer.create(<Slider disabled />)).toMatchSnapshot(); | ||
expect( | ||
ReactTestRenderer.create( | ||
<Slider accessibilityState={{disabled: true}} />, | ||
), | ||
).toMatchSnapshot(); | ||
}); | ||
}); |
121 changes: 121 additions & 0 deletions
121
Libraries/Components/__tests__/__snapshots__/Slider-test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<Slider /> should render as expected 1`] = ` | ||
<RCTSlider | ||
disabled={false} | ||
enabled={true} | ||
maximumValue={1} | ||
minimumValue={0} | ||
onChange={null} | ||
onResponderTerminationRequest={[Function]} | ||
onSlidingComplete={null} | ||
onStartShouldSetResponder={[Function]} | ||
onValueChange={null} | ||
step={0} | ||
style={ | ||
Object { | ||
"height": 40, | ||
} | ||
} | ||
value={0.5} | ||
/> | ||
`; | ||
|
||
exports[`<Slider /> should set disabled as false 1`] = ` | ||
<RCTSlider | ||
disabled={false} | ||
enabled={true} | ||
maximumValue={1} | ||
minimumValue={0} | ||
onChange={null} | ||
onResponderTerminationRequest={[Function]} | ||
onSlidingComplete={null} | ||
onStartShouldSetResponder={[Function]} | ||
onValueChange={null} | ||
step={0} | ||
style={ | ||
Object { | ||
"height": 40, | ||
} | ||
} | ||
value={0.5} | ||
/> | ||
`; | ||
|
||
exports[`<Slider /> should set disabled as false 2`] = ` | ||
<RCTSlider | ||
accessibilityState={ | ||
Object { | ||
"disabled": false, | ||
} | ||
} | ||
disabled={false} | ||
enabled={true} | ||
maximumValue={1} | ||
minimumValue={0} | ||
onChange={null} | ||
onResponderTerminationRequest={[Function]} | ||
onSlidingComplete={null} | ||
onStartShouldSetResponder={[Function]} | ||
onValueChange={null} | ||
step={0} | ||
style={ | ||
Object { | ||
"height": 40, | ||
} | ||
} | ||
value={0.5} | ||
/> | ||
`; | ||
|
||
exports[`<Slider /> should set disabled as true 1`] = ` | ||
<RCTSlider | ||
accessibilityState={ | ||
Object { | ||
"disabled": true, | ||
} | ||
} | ||
disabled={true} | ||
enabled={false} | ||
maximumValue={1} | ||
minimumValue={0} | ||
onChange={null} | ||
onResponderTerminationRequest={[Function]} | ||
onSlidingComplete={null} | ||
onStartShouldSetResponder={[Function]} | ||
onValueChange={null} | ||
step={0} | ||
style={ | ||
Object { | ||
"height": 40, | ||
} | ||
} | ||
value={0.5} | ||
/> | ||
`; | ||
|
||
exports[`<Slider /> should set disabled as true 2`] = ` | ||
<RCTSlider | ||
accessibilityState={ | ||
Object { | ||
"disabled": true, | ||
} | ||
} | ||
disabled={true} | ||
enabled={false} | ||
maximumValue={1} | ||
minimumValue={0} | ||
onChange={null} | ||
onResponderTerminationRequest={[Function]} | ||
onSlidingComplete={null} | ||
onStartShouldSetResponder={[Function]} | ||
onValueChange={null} | ||
step={0} | ||
style={ | ||
Object { | ||
"height": 40, | ||
} | ||
} | ||
value={0.5} | ||
/> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters