React Native accessibility (#539)

* React Native accessibility

* First round of changes

* Latest update

* Checkpoint

* Wrap up

* Lint

* Remove unhelpful image hints

* Fix navigation

* Fix rebase and lint

* Mitigate an known issue with the password entry in login

* Fix composer dismiss

* Remove focus on input elements for web

* Remove i and npm

* pls work

* Remove stray declaration

* Regenerate yarn.lock

---------

Co-authored-by: Paul Frazee <pfrazee@gmail.com>
This commit is contained in:
Ollie H 2023-05-01 18:38:47 -07:00 committed by GitHub
parent c75c888de2
commit 83959c595d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
86 changed files with 2479 additions and 1827 deletions

View file

@ -62,12 +62,17 @@ export function AutoSizedImage({
onLongPress={onLongPress}
onPressIn={onPressIn}
delayPressIn={DELAY_PRESS_IN}
style={[styles.container, style]}>
style={[styles.container, style]}
accessible={true}
accessibilityLabel="Share image"
accessibilityHint="Opens ways of sharing image">
<Image
style={[styles.image, {aspectRatio}]}
source={uri}
accessible={true} // Must set for `accessibilityLabel` to work
accessibilityIgnoresInvertColors
accessibilityLabel={alt}
accessibilityHint=""
/>
{children}
</TouchableOpacity>
@ -80,7 +85,9 @@ export function AutoSizedImage({
style={[styles.image, {aspectRatio}]}
source={{uri}}
accessible={true} // Must set for `accessibilityLabel` to work
accessibilityIgnoresInvertColors
accessibilityLabel={alt}
accessibilityHint=""
/>
{children}
</View>

View file

@ -41,16 +41,25 @@ export const GalleryItem: FC<GalleryItemProps> = ({
delayPressIn={DELAY_PRESS_IN}
onPress={() => onPress?.(index)}
onPressIn={() => onPressIn?.(index)}
onLongPress={() => onLongPress?.(index)}>
onLongPress={() => onLongPress?.(index)}
accessibilityRole="button"
accessibilityLabel="View image"
accessibilityHint="">
<Image
source={{uri: image.thumb}}
style={imageStyle}
accessible={true}
accessibilityLabel={image.alt}
accessibilityHint=""
accessibilityIgnoresInvertColors
/>
</TouchableOpacity>
{image.alt === '' ? null : (
<Pressable onPress={onPressAltText}>
<Pressable
onPress={onPressAltText}
accessibilityRole="button"
accessibilityLabel="View alt text"
accessibilityHint="Opens modal with alt text">
<Text style={styles.alt}>ALT</Text>
</Pressable>
)}

View file

@ -8,5 +8,7 @@ export function HighPriorityImage({source, ...props}: HighPriorityImageProps) {
const updatedSource = {
uri: typeof source === 'object' && source ? source.uri : '',
} satisfies ImageSource
return <Image source={updatedSource} {...props} />
return (
<Image accessibilityIgnoresInvertColors source={updatedSource} {...props} />
)
}

View file

@ -16,15 +16,33 @@ interface Props {
}
export function ImageHorzList({images, onPress, style}: Props) {
const numImages = images.length
return (
<View style={[styles.flexRow, style]}>
{images.map(({thumb, alt}, i) => (
<TouchableWithoutFeedback key={i} onPress={() => onPress?.(i)}>
<TouchableWithoutFeedback
key={i}
onPress={() => onPress?.(i)}
accessible={true}
accessibilityLabel={`Open image ${i} of ${numImages}`}
accessibilityHint="Opens image in viewer"
accessibilityActions={[{name: 'press', label: 'Press'}]}
onAccessibilityAction={action => {
switch (action.nativeEvent.actionName) {
case 'press':
onPress?.(0)
break
default:
break
}
}}>
<Image
source={{uri: thumb}}
style={styles.image}
accessible={true}
accessibilityLabel={alt}
accessibilityIgnoresInvertColors
accessibilityHint={alt}
accessibilityLabel=""
/>
</TouchableWithoutFeedback>
))}