Skip to content
Open
9 changes: 8 additions & 1 deletion src/components/MagicCodeInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {StyleSheet, View} from 'react-native';
import {Gesture, GestureDetector} from 'react-native-gesture-handler';
import Animated, {useAnimatedStyle, useSharedValue, withDelay, withRepeat, withSequence, withTiming} from 'react-native-reanimated';
import type {ValueOf} from 'type-fest';
import useAccessibilityAnnouncement from '@hooks/useAccessibilityAnnouncement';
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
import useStyleUtils from '@hooks/useStyleUtils';
Expand Down Expand Up @@ -213,6 +214,9 @@ function MagicCodeInput({
editIndex.current = index;
};

const announcement = focusedIndex !== undefined ? translate('common.enterDigitLabel', {digitIndex: focusedIndex + 1, totalDigits: maxLength}) : undefined;
useAccessibilityAnnouncement(announcement, !!announcement, {shouldAnnounceOnNative: true, shouldAnnounceOnWeb: true});

useImperativeHandle(ref, () => ({
focus() {
focusMagicCodeInput();
Expand Down Expand Up @@ -467,7 +471,7 @@ function MagicCodeInput({
<GestureDetector gesture={tapGesture}>
{/* Android does not handle touch on invisible Views so I created a wrapper around invisible TextInput just to handle taps */}
<View
style={[StyleSheet.absoluteFillObject, styles.w100, styles.h100, styles.invisibleOverlay]}
style={[StyleSheet.absoluteFill, styles.w100, styles.h100, styles.invisibleOverlay]}
collapsable={false}
>
<TextInput
Expand Down Expand Up @@ -512,6 +516,8 @@ function MagicCodeInput({

return (
<View
accessibilityElementsHidden
importantForAccessibility="no-hide-descendants"
Comment on lines +519 to +520

Choose a reason for hiding this comment

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

P1 Badge Keep the entered code value accessible to screen readers

Hiding every digit cell here removes the only accessible copy of the code. The backing TextInput still uses value={input}, and setInputAndIndex() clears that state whenever the cursor moves, so after this change a screen reader can only hear the generic input label plus the new position alert. In OTP/PIN flows, users revisiting a slot can no longer tell whether it already contains a digit or what they are correcting.

Useful? React with 👍 / 👎.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@MelvinBot Do you have any suggestions on this?

Should we update the announcement parameter passed in useAccessibilityAnnouncement so that it also reflects the current digit?

key={index}
style={maxLength === CONST.MAGIC_CODE_LENGTH ? [styles.w15] : [styles.flex1, index !== 0 && styles.ml3]}
>
Expand All @@ -533,6 +539,7 @@ function MagicCodeInput({
accessibilityElementsHidden
importantForAccessibility="no-hide-descendants"
accessible={false}
aria-hidden
>
{!!char && <Text style={[styles.magicCodeInput, styles.textAlignCenter, styles.opacity0]}>{char}</Text>}
<Text style={[styles.magicCodeInput, {width: 1}]}> </Text>
Expand Down
1 change: 1 addition & 0 deletions src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ const translations: TranslationDeepObject<typeof en> = {
concierge: {sidePanelGreeting: 'Hallo, wie kann ich helfen?', showHistory: 'Verlauf anzeigen'},
duplicateReport: 'Duplizierten Bericht',
approver: 'Genehmiger',
enterDigitLabel: ({digitIndex, totalDigits}: {digitIndex: number; totalDigits: number}) => `Ziffer ${digitIndex} von ${totalDigits} eingeben`,
copyOfReportName: (reportName: string) => `Kopie von ${reportName}`,
},
socials: {
Expand Down
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ const translations = {
vacationDelegate: 'Vacation delegate',
expensifyLogo: 'Expensify logo',
approver: 'Approver',
enterDigitLabel: ({digitIndex, totalDigits}: {digitIndex: number; totalDigits: number}) => `enter digit ${digitIndex} of ${totalDigits}`,
},
socials: {
podcast: 'Follow us on Podcast',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ const translations: TranslationDeepObject<typeof en> = {
vacationDelegate: 'Delegado de vacaciones',
expensifyLogo: 'Logo de Expensify',
approver: 'Aprobador',
enterDigitLabel: ({digitIndex, totalDigits}: {digitIndex: number; totalDigits: number}) => `introducir dígito ${digitIndex} de ${totalDigits}`,
},
socials: {
podcast: 'Síguenos en Podcast',
Expand Down
1 change: 1 addition & 0 deletions src/languages/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ const translations: TranslationDeepObject<typeof en> = {
concierge: {sidePanelGreeting: 'Bonjour, comment puis-je vous aider ?', showHistory: 'Afficher l’historique'},
duplicateReport: 'Note de frais en double',
approver: 'Approbateur',
enterDigitLabel: ({digitIndex, totalDigits}: {digitIndex: number; totalDigits: number}) => `saisir le chiffre ${digitIndex} sur ${totalDigits}`,
copyOfReportName: (reportName: string) => `Copie de ${reportName}`,
},
socials: {
Expand Down
1 change: 1 addition & 0 deletions src/languages/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ const translations: TranslationDeepObject<typeof en> = {
concierge: {sidePanelGreeting: 'Ciao, come posso aiutarti?', showHistory: 'Mostra cronologia'},
duplicateReport: 'Report duplicato',
approver: 'Approvante',
enterDigitLabel: ({digitIndex, totalDigits}: {digitIndex: number; totalDigits: number}) => `inserire la cifra ${digitIndex} di ${totalDigits}`,
copyOfReportName: (reportName: string) => `Copia di ${reportName}`,
},
socials: {
Expand Down
1 change: 1 addition & 0 deletions src/languages/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ const translations: TranslationDeepObject<typeof en> = {
concierge: {sidePanelGreeting: 'こんにちは、どのようにお手伝いできますか?', showHistory: '履歴を表示'},
duplicateReport: 'レポートを複製',
approver: '承認者',
enterDigitLabel: ({digitIndex, totalDigits}: {digitIndex: number; totalDigits: number}) => `${totalDigits}桁中${digitIndex}桁目を入力`,
copyOfReportName: (reportName: string) => `${reportName} のコピー`,
},
socials: {
Expand Down
1 change: 1 addition & 0 deletions src/languages/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ const translations: TranslationDeepObject<typeof en> = {
concierge: {sidePanelGreeting: 'Hoi, waarmee kan ik je helpen?', showHistory: 'Geschiedenis weergeven'},
duplicateReport: 'Dubbel rapport',
approver: 'Fiatteur',
enterDigitLabel: ({digitIndex, totalDigits}: {digitIndex: number; totalDigits: number}) => `voer cijfer ${digitIndex} van ${totalDigits} in`,
copyOfReportName: (reportName: string) => `Kopie van ${reportName}`,
},
socials: {
Expand Down
1 change: 1 addition & 0 deletions src/languages/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ const translations: TranslationDeepObject<typeof en> = {
concierge: {sidePanelGreeting: 'Cześć, w czym mogę pomóc?', showHistory: 'Pokaż historię'},
duplicateReport: 'Zduplikowany raport',
approver: 'Osoba zatwierdzająca',
enterDigitLabel: ({digitIndex, totalDigits}: {digitIndex: number; totalDigits: number}) => `wprowadź cyfrę ${digitIndex} z ${totalDigits}`,
copyOfReportName: (reportName: string) => `Kopia raportu ${reportName}`,
},
socials: {
Expand Down
1 change: 1 addition & 0 deletions src/languages/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ const translations: TranslationDeepObject<typeof en> = {
concierge: {sidePanelGreeting: 'Oi, como posso ajudar?', showHistory: 'Mostrar histórico'},
duplicateReport: 'Duplicar relatório',
approver: 'Aprovador',
enterDigitLabel: ({digitIndex, totalDigits}: {digitIndex: number; totalDigits: number}) => `inserir dígito ${digitIndex} de ${totalDigits}`,
copyOfReportName: (reportName: string) => `Cópia de ${reportName}`,
},
socials: {
Expand Down
1 change: 1 addition & 0 deletions src/languages/zh-hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ const translations: TranslationDeepObject<typeof en> = {
concierge: {sidePanelGreeting: '你好,我能帮你做什么?', showHistory: '显示历史'},
duplicateReport: '重复报销单',
approver: '审批人',
enterDigitLabel: ({digitIndex, totalDigits}: {digitIndex: number; totalDigits: number}) => `输入第 ${digitIndex} 位数字,共 ${totalDigits} 位`,
copyOfReportName: (reportName: string) => `${reportName} 的副本`,
},
socials: {
Expand Down
Loading