From 83959c595d52ceb7aa4e3f68441c5ac41c389ebc Mon Sep 17 00:00:00 2001 From: Ollie H Date: Mon, 1 May 2023 18:38:47 -0700 Subject: 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 --- src/view/com/composer/Composer.tsx | 274 ++++++++++++++++++------------------- 1 file changed, 135 insertions(+), 139 deletions(-) (limited to 'src/view/com/composer/Composer.tsx') diff --git a/src/view/com/composer/Composer.tsx b/src/view/com/composer/Composer.tsx index 5ccc229d6..45e67d7cb 100644 --- a/src/view/com/composer/Composer.tsx +++ b/src/view/com/composer/Composer.tsx @@ -7,7 +7,6 @@ import { ScrollView, StyleSheet, TouchableOpacity, - TouchableWithoutFeedback, View, } from 'react-native' import {useSafeAreaInsets} from 'react-native-safe-area-context' @@ -19,6 +18,8 @@ import {UserAutocompleteModel} from 'state/models/discovery/user-autocomplete' import {ExternalEmbed} from './ExternalEmbed' import {Text} from '../util/text/Text' import * as Toast from '../util/Toast' +// TODO: Prevent naming components that coincide with RN primitives +// due to linting false positives import {TextInput, TextInputRef} from './text-input/TextInput' import {CharProgress} from './char-progress/CharProgress' import {UserAvatar} from '../util/UserAvatar' @@ -87,27 +88,6 @@ export const ComposePost = observer(function ComposePost({ autocompleteView.setup() }, [autocompleteView]) - useEffect(() => { - // HACK - // wait a moment before focusing the input to resolve some layout bugs with the keyboard-avoiding-view - // -prf - let to: NodeJS.Timeout | undefined - if (textInput.current) { - to = setTimeout(() => { - textInput.current?.focus() - }, 250) - } - return () => { - if (to) { - clearTimeout(to) - } - } - }, []) - - const onPressContainer = useCallback(() => { - textInput.current?.focus() - }, [textInput]) - const onPressAddLinkCard = useCallback( (uri: string) => { setExtLink({uri, isLoading: true}) @@ -133,7 +113,7 @@ export const ComposePost = observer(function ComposePost({ if (rt.text.trim().length === 0 && gallery.isEmpty) { setError('Did you want to say anything?') - return false + return } setIsProcessing(true) @@ -203,133 +183,149 @@ export const ComposePost = observer(function ComposePost({ testID="composePostView" behavior={Platform.OS === 'ios' ? 'padding' : 'height'} style={styles.outer}> - - - + + + + Cancel + + + {isProcessing ? ( + + + + ) : canPost ? ( - Cancel + testID="composerPublishBtn" + onPress={() => { + onPressPublish(richtext) + }} + accessibilityRole="button" + accessibilityLabel={replyTo ? 'Publish reply' : 'Publish post'} + accessibilityHint={ + replyTo + ? 'Double tap to publish your reply' + : 'Double tap to publish your post' + }> + + + {replyTo ? 'Reply' : 'Post'} + + - - {isProcessing ? ( - - - - ) : canPost ? ( - { - onPressPublish(richtext) - }}> - - - {replyTo ? 'Reply' : 'Post'} - - - - ) : ( - - Post - - )} + ) : ( + + Post + + )} + + {isProcessing ? ( + + {processingState} - {isProcessing ? ( - - {processingState} + ) : undefined} + {error !== '' && ( + + + - ) : undefined} - {error !== '' && ( - - - + {error} + + )} + + {replyTo ? ( + + + + + {sanitizeDisplayName( + replyTo.author.displayName || replyTo.author.handle, + )} + + + {replyTo.text} + - {error} - )} - - {replyTo ? ( - - - - - {sanitizeDisplayName( - replyTo.author.displayName || replyTo.author.handle, - )} - - - {replyTo.text} - - - - ) : undefined} + ) : undefined} - - - - + + + + - - {gallery.isEmpty && extLink && ( - setExtLink(undefined)} - /> - )} - {quote ? ( - - - - ) : undefined} - - {!extLink && suggestedLinks.size > 0 ? ( - - {Array.from(suggestedLinks).map(url => ( - onPressAddLinkCard(url)}> - - Add link card: {url} - - - ))} + + {gallery.isEmpty && extLink && ( + setExtLink(undefined)} + /> + )} + {quote ? ( + + - ) : null} - - {canSelectImages ? ( - <> - - - - ) : null} - - + ) : undefined} + + {!extLink && suggestedLinks.size > 0 ? ( + + {Array.from(suggestedLinks).map(url => ( + onPressAddLinkCard(url)} + accessibilityRole="button" + accessibilityLabel="Add link card" + accessibilityHint={`Creates a card with a thumbnail. The card links to ${url}`}> + + Add link card: {url} + + + ))} + ) : null} + + {canSelectImages ? ( + <> + + + + ) : null} + + - + ) }) -- cgit 1.4.1