[英]How to make screen reader read out a validation error text that appears if the user tries to submit invalid information?
我有一個包含輸入的 TextInput 組件和一個僅在出現錯誤時出現的 HelperText。 我想知道如何才能使屏幕閱讀器在元素出現錯誤文本后讀取錯誤?
<TextInputBase
onFocus={(e) => {
setIsFocused(true);
onFocus?.(e);
}}
onBlur={(e) => {
setIsFocused(false);
onBlur?.(e);
}}
outlineColor={colors.gray200}
activeOutlineColor={colors.primary600}
accessibilityLabel={label}
label={label}
error={!!error}
// Hide the placeholder when the input is focused
placeholder={isFocused ? undefined : label}
theme={{ colors: { text: colors.black, placeholder: colors.gray800 } }}
style={[style, styles.input]}
{...rest}
/>
<HelperText
type="error"
visible={!!error}
>
{error}
</HelperText>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.