Skip to content

Commit

Permalink
fix(Slider): make screen readers recognize correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
grgr-dkrk committed Oct 18, 2021
1 parent 8fa432d commit 1d226d9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
39 changes: 26 additions & 13 deletions src/components/primitives/Slider/SliderThumb.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { forwardRef } from 'react';
import { Platform } from 'react-native';
import { Platform, StyleSheet } from 'react-native';
import { useSliderThumb } from '@react-native-aria/slider';
import { VisuallyHidden } from '@react-aria/visually-hidden';
import { useToken } from '../../../hooks';
Expand Down Expand Up @@ -64,22 +64,35 @@ function SliderThumb(props: ISliderThumbProps, ref: any) {
return null;
}

const styles = StyleSheet.create({
wrapper: {
width: '100%',
},
});

return (
<Box
accessible
{...inputProps}
position="absolute"
{...thumbProps}
{...resolvedProps}
ref={ref}
style={[thumbStyles, props.style]}
// {...(isReadOnly && _readOnly)}
// {...(isDisabled && _disabled)}
pointerEvents="box-none"
style={styles.wrapper}
>
{props.children}
{Platform.OS === 'web' && (
<VisuallyHidden>
<input ref={inputRef} {...inputProps} />
</VisuallyHidden>
)}
<Box
{...thumbProps}
{...resolvedProps}
ref={ref}
style={[thumbStyles, props.style]}
// {...(isReadOnly && _readOnly)}
// {...(isDisabled && _disabled)}
>
{props.children}
{Platform.OS === 'web' && (
<VisuallyHidden>
<input ref={inputRef} {...inputProps} />
</VisuallyHidden>
)}
</Box>
</Box>
);
}
Expand Down
2 changes: 2 additions & 0 deletions src/components/primitives/Slider/SliderTrack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ const SliderTrack = ({ children, ...props }: ISliderTrackProps, ref?: any) => {

return (
<Pressable
accessible={false}
importantForAccessibility={'no-hide-descendants'}
onLayout={onTrackLayout}
ref={ref}
{...trackProps}
Expand Down

0 comments on commit 1d226d9

Please sign in to comment.