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/30842 - Add accessibilityState prop in slider #31145

Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Libraries/Components/Slider/Slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import type {ViewStyleProp} from '../../StyleSheet/StyleSheet';
import type {ColorValue} from '../../StyleSheet/StyleSheet';
import type {ViewProps} from '../View/ViewPropTypes';
import type {SyntheticEvent} from '../../Types/CoreEventTypes';
import type {AccessibilityState} from './View/ViewAccessibility';

type Event = SyntheticEvent<
$ReadOnly<{|
Expand Down Expand Up @@ -130,6 +131,12 @@ type Props = $ReadOnly<{|
* Used to locate this view in UI automation tests.
*/
testID?: ?string,

/**
Indicates to accessibility services that UI Component is in a specific State.
*/
accessibilityState?: ?AccessibilityState,

|}>;

/**
Expand Down Expand Up @@ -197,6 +204,7 @@ const Slider = (
forwardedRef?: ?React.Ref<typeof SliderNativeComponent>,
) => {
const style = StyleSheet.compose(styles.slider, props.style);
const accessibilityState = props.accessibilityState || {};
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need to be an empty object if no props.accessibilityState? It seems like SliderNativeComponent allows for null value for accessibilityState prop. In this approach you'd be a creating a non-used new object every time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I was wondering too, so should we just omit the empty object since props.accessibilityState would return null if its empty

Copy link
Contributor

Choose a reason for hiding this comment

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

Yea we can directly pass the prop to the native component.


const {
disabled = false,
Expand Down Expand Up @@ -233,6 +241,7 @@ const Slider = (
<SliderNativeComponent
{...localProps}
// TODO: Reconcile these across the two platforms.
accessibilityState={accessibilityState}
enabled={!disabled}
disabled={disabled}
maximumValue={maximumValue}
Expand Down