mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Back out "1/2 TextInput accessibilityErrorMessage (Talkback, Android)"
Summary: This diff is reverting PR https://github.com/facebook/react-native/pull/33468 Due to an increase of java.lang.IllegalStateException caused by the PR Original commit changeset: cd80e9a1be8f Original Phabricator Diff: D38410635 Changelog: [Android][Fixed] - removed logic that calls the [AccessibilityNodeInfo#setError][10] and [#setContentInvalid][13] method to display the error message in the TextInput - Revert of PR https://github.com/facebook/react-native/pull/33468 Reviewed By: NickGerleman, makovkastar Differential Revision: D44032331 fbshipit-source-id: 732ed0cf23e4f30ae00c51dace851a3fdfe65c01
This commit is contained in:
committed by
Facebook GitHub Bot
parent
21d530208f
commit
ca0d565a3c
@@ -166,14 +166,6 @@ export type NativeProps = $ReadOnly<{|
|
||||
'off',
|
||||
>,
|
||||
|
||||
/**
|
||||
* String to be read by screenreaders to indicate an error state. The acceptable parameters
|
||||
* of accessibilityErrorMessage is a string. Setting accessibilityInvalid to true activates
|
||||
* the error message. Setting accessibilityInvalid to false removes the error message.
|
||||
*/
|
||||
accessibilityErrorMessage?: ?Stringish,
|
||||
accessibilityInvalid?: ?boolean,
|
||||
|
||||
/**
|
||||
* Sets the return key to the label. Use it instead of `returnKeyType`.
|
||||
* @platform android
|
||||
@@ -738,8 +730,6 @@ export const __INTERNAL_VIEW_CONFIG: PartialViewConfig = {
|
||||
inlineImageLeft: true,
|
||||
editable: true,
|
||||
fontVariant: true,
|
||||
accessibilityErrorMessage: true,
|
||||
accessibilityInvalid: true,
|
||||
borderBottomRightRadius: true,
|
||||
borderBottomColor: {
|
||||
process: require('../../StyleSheet/processColor').default,
|
||||
|
||||
@@ -531,14 +531,6 @@ export interface TextInputProps
|
||||
TextInputIOSProps,
|
||||
TextInputAndroidProps,
|
||||
AccessibilityProps {
|
||||
/**
|
||||
* String to be read by screenreaders to indicate an error state. The acceptable parameters
|
||||
* of accessibilityErrorMessage is a string. Setting accessibilityInvalid to true activates
|
||||
* the error message. Setting accessibilityInvalid to false removes the error message.
|
||||
*/
|
||||
accessibilityErrorMessage?: string | undefined;
|
||||
accessibilityInvalid?: boolean | undefined;
|
||||
|
||||
/**
|
||||
* Specifies whether fonts should scale to respect Text Size accessibility settings.
|
||||
* The default is `true`.
|
||||
|
||||
@@ -523,14 +523,6 @@ export type Props = $ReadOnly<{|
|
||||
...IOSProps,
|
||||
...AndroidProps,
|
||||
|
||||
/**
|
||||
* String to be read by screenreaders to indicate an error state. The acceptable parameters
|
||||
* of accessibilityErrorMessage is a string. Setting accessibilityInvalid to true activates
|
||||
* the error message. Setting accessibilityInvalid to false removes the error message.
|
||||
*/
|
||||
accessibilityErrorMessage?: ?Stringish,
|
||||
accessibilityInvalid?: ?boolean,
|
||||
|
||||
/**
|
||||
* Can tell `TextInput` to automatically capitalize certain characters.
|
||||
*
|
||||
|
||||
@@ -561,14 +561,6 @@ export type Props = $ReadOnly<{|
|
||||
...IOSProps,
|
||||
...AndroidProps,
|
||||
|
||||
/**
|
||||
* String to be read by screenreaders to indicate an error state. The acceptable parameters
|
||||
* of accessibilityErrorMessage is a string. Setting accessibilityInvalid to true activates
|
||||
* the error message. Setting accessibilityInvalid to false removes the error message.
|
||||
*/
|
||||
accessibilityErrorMessage?: ?Stringish,
|
||||
accessibilityInvalid?: ?boolean,
|
||||
|
||||
/**
|
||||
* Can tell `TextInput` to automatically capitalize certain characters.
|
||||
*
|
||||
@@ -1373,12 +1365,6 @@ function InternalTextInput(props: Props): React.Node {
|
||||
}
|
||||
|
||||
const accessible = props.accessible !== false;
|
||||
|
||||
const accessibilityErrorMessage =
|
||||
props.accessibilityInvalid === true
|
||||
? props.accessibilityErrorMessage
|
||||
: null;
|
||||
|
||||
const focusable = props.focusable !== false;
|
||||
|
||||
const config = React.useMemo(
|
||||
@@ -1453,7 +1439,6 @@ function InternalTextInput(props: Props): React.Node {
|
||||
ref={ref}
|
||||
{...otherProps}
|
||||
{...eventHandlers}
|
||||
accessibilityErrorMessage={accessibilityErrorMessage}
|
||||
accessibilityState={_accessibilityState}
|
||||
accessible={accessible}
|
||||
submitBehavior={submitBehavior}
|
||||
@@ -1505,7 +1490,6 @@ function InternalTextInput(props: Props): React.Node {
|
||||
ref={ref}
|
||||
{...otherProps}
|
||||
{...eventHandlers}
|
||||
accessibilityErrorMessage={accessibilityErrorMessage}
|
||||
accessibilityState={_accessibilityState}
|
||||
accessibilityLabelledBy={_accessibilityLabelledBy}
|
||||
accessible={accessible}
|
||||
|
||||
@@ -186,7 +186,6 @@ describe('TextInput', () => {
|
||||
|
||||
expect(instance.toJSON()).toMatchInlineSnapshot(`
|
||||
<RCTSinglelineTextInputView
|
||||
accessibilityErrorMessage={null}
|
||||
accessible={true}
|
||||
allowFontScaling={true}
|
||||
focusable={true}
|
||||
@@ -232,7 +231,6 @@ describe('TextInput compat with web', () => {
|
||||
|
||||
expect(instance.toJSON()).toMatchInlineSnapshot(`
|
||||
<RCTSinglelineTextInputView
|
||||
accessibilityErrorMessage={null}
|
||||
accessible={true}
|
||||
allowFontScaling={true}
|
||||
focusable={true}
|
||||
@@ -317,7 +315,6 @@ describe('TextInput compat with web', () => {
|
||||
|
||||
expect(instance.toJSON()).toMatchInlineSnapshot(`
|
||||
<RCTSinglelineTextInputView
|
||||
accessibilityErrorMessage={null}
|
||||
accessibilityState={
|
||||
Object {
|
||||
"busy": true,
|
||||
@@ -409,7 +406,6 @@ describe('TextInput compat with web', () => {
|
||||
|
||||
expect(instance.toJSON()).toMatchInlineSnapshot(`
|
||||
<RCTSinglelineTextInputView
|
||||
accessibilityErrorMessage={null}
|
||||
accessible={true}
|
||||
allowFontScaling={true}
|
||||
focusable={true}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
exports[`TextInput tests should render as expected: should deep render when mocked (please verify output manually) 1`] = `
|
||||
<RCTSinglelineTextInputView
|
||||
accessibilityErrorMessage={null}
|
||||
accessible={true}
|
||||
allowFontScaling={true}
|
||||
focusable={true}
|
||||
@@ -32,7 +31,6 @@ exports[`TextInput tests should render as expected: should deep render when mock
|
||||
|
||||
exports[`TextInput tests should render as expected: should deep render when not mocked (please verify output manually) 1`] = `
|
||||
<RCTSinglelineTextInputView
|
||||
accessibilityErrorMessage={null}
|
||||
accessible={true}
|
||||
allowFontScaling={true}
|
||||
focusable={true}
|
||||
|
||||
@@ -251,11 +251,6 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
|
||||
view.setTag(R.id.accessibility_role, AccessibilityRole.fromValue(accessibilityRole));
|
||||
}
|
||||
|
||||
@ReactProp(name = "accessibilityErrorMessage")
|
||||
public void setScreenreaderError(@NonNull T view, @Nullable String accessibilityErrorMessage) {
|
||||
view.setTag(R.id.accessibility_error_message, accessibilityErrorMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ReactProp(name = ViewProps.ACCESSIBILITY_COLLECTION)
|
||||
public void setAccessibilityCollection(
|
||||
|
||||
@@ -11,7 +11,6 @@ import static com.facebook.react.views.text.TextAttributeProps.UNSET;
|
||||
|
||||
import android.text.Layout;
|
||||
import android.text.Spannable;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Class that contains the data needed for a text update. Used by both <Text/> and <TextInput/>
|
||||
@@ -31,7 +30,6 @@ public class ReactTextUpdate {
|
||||
private final int mSelectionStart;
|
||||
private final int mSelectionEnd;
|
||||
private final int mJustificationMode;
|
||||
private @Nullable String mAccessibilityErrorMessage;
|
||||
|
||||
public boolean mContainsMultipleFragments;
|
||||
|
||||
@@ -61,8 +59,7 @@ public class ReactTextUpdate {
|
||||
Layout.BREAK_STRATEGY_HIGH_QUALITY,
|
||||
Layout.JUSTIFICATION_MODE_NONE,
|
||||
-1,
|
||||
-1,
|
||||
null);
|
||||
-1);
|
||||
}
|
||||
|
||||
public ReactTextUpdate(
|
||||
@@ -88,8 +85,7 @@ public class ReactTextUpdate {
|
||||
textBreakStrategy,
|
||||
justificationMode,
|
||||
-1,
|
||||
-1,
|
||||
null);
|
||||
-1);
|
||||
}
|
||||
|
||||
public ReactTextUpdate(
|
||||
@@ -111,8 +107,7 @@ public class ReactTextUpdate {
|
||||
textBreakStrategy,
|
||||
justificationMode,
|
||||
-1,
|
||||
-1,
|
||||
null);
|
||||
-1);
|
||||
}
|
||||
|
||||
public ReactTextUpdate(
|
||||
@@ -142,56 +137,21 @@ public class ReactTextUpdate {
|
||||
mJustificationMode = justificationMode;
|
||||
}
|
||||
|
||||
public ReactTextUpdate(
|
||||
Spannable text,
|
||||
int jsEventCounter,
|
||||
boolean containsImages,
|
||||
float paddingStart,
|
||||
float paddingTop,
|
||||
float paddingEnd,
|
||||
float paddingBottom,
|
||||
int textAlign,
|
||||
int textBreakStrategy,
|
||||
int justificationMode,
|
||||
int selectionStart,
|
||||
int selectionEnd,
|
||||
@Nullable String accessibilityErrorMessage) {
|
||||
mText = text;
|
||||
mJsEventCounter = jsEventCounter;
|
||||
mContainsImages = containsImages;
|
||||
mPaddingLeft = paddingStart;
|
||||
mPaddingTop = paddingTop;
|
||||
mPaddingRight = paddingEnd;
|
||||
mPaddingBottom = paddingBottom;
|
||||
mTextAlign = textAlign;
|
||||
mTextBreakStrategy = textBreakStrategy;
|
||||
mSelectionStart = selectionStart;
|
||||
mSelectionEnd = selectionEnd;
|
||||
mJustificationMode = justificationMode;
|
||||
mAccessibilityErrorMessage = accessibilityErrorMessage;
|
||||
}
|
||||
|
||||
public static ReactTextUpdate buildReactTextUpdateFromState(
|
||||
Spannable text,
|
||||
int jsEventCounter,
|
||||
int textAlign,
|
||||
int textBreakStrategy,
|
||||
int justificationMode,
|
||||
boolean containsMultipleFragments,
|
||||
@Nullable String accessibilityErrorMessage) {
|
||||
boolean containsMultipleFragments) {
|
||||
|
||||
ReactTextUpdate reactTextUpdate =
|
||||
new ReactTextUpdate(
|
||||
text, jsEventCounter, false, textAlign, textBreakStrategy, justificationMode);
|
||||
reactTextUpdate.mContainsMultipleFragments = containsMultipleFragments;
|
||||
reactTextUpdate.mAccessibilityErrorMessage = accessibilityErrorMessage;
|
||||
return reactTextUpdate;
|
||||
}
|
||||
|
||||
public @Nullable String getScreenreaderError() {
|
||||
return mAccessibilityErrorMessage;
|
||||
}
|
||||
|
||||
public Spannable getText() {
|
||||
return mText;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ rn_android_library(
|
||||
react_native_target("java/com/facebook/react/common/mapbuffer:mapbuffer"),
|
||||
react_native_target("java/com/facebook/react/views/view:view"),
|
||||
react_native_target("java/com/facebook/react/config:config"),
|
||||
react_native_target("res:uimanager"),
|
||||
] + KOTLIN_STDLIB_DEPS,
|
||||
exported_deps = [
|
||||
react_native_dep("third-party/android/androidx:appcompat"),
|
||||
|
||||
@@ -30,7 +30,6 @@ import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputConnection;
|
||||
@@ -38,10 +37,8 @@ import android.view.inputmethod.InputMethodManager;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.AppCompatEditText;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
|
||||
import com.facebook.common.logging.FLog;
|
||||
import com.facebook.infer.annotation.Assertions;
|
||||
import com.facebook.react.R;
|
||||
import com.facebook.react.bridge.ReactContext;
|
||||
import com.facebook.react.bridge.ReactSoftExceptionLogger;
|
||||
import com.facebook.react.common.build.ReactBuildConfig;
|
||||
@@ -160,36 +157,6 @@ public class ReactEditText extends AppCompatEditText
|
||||
ReactAccessibilityDelegate editTextAccessibilityDelegate =
|
||||
new ReactAccessibilityDelegate(
|
||||
this, this.isFocusable(), this.getImportantForAccessibility()) {
|
||||
@Override
|
||||
public void onInitializeAccessibilityNodeInfo(
|
||||
View host, AccessibilityNodeInfoCompat info) {
|
||||
super.onInitializeAccessibilityNodeInfo(host, info);
|
||||
final String accessibilityErrorMessage =
|
||||
(String) host.getTag(R.id.accessibility_error_message);
|
||||
boolean contentInvalid = accessibilityErrorMessage == null ? false : true;
|
||||
if (accessibilityErrorMessage != info.getError()) {
|
||||
info.setError(accessibilityErrorMessage);
|
||||
info.setContentInvalid(contentInvalid);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
|
||||
super.onInitializeAccessibilityEvent(host, event);
|
||||
if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED
|
||||
&& host.getParent() != null) {
|
||||
try {
|
||||
host.getParent().requestSendAccessibilityEvent(host, event);
|
||||
} catch (AbstractMethodError e) {
|
||||
FLog.w(
|
||||
TAG,
|
||||
host.getParent().getClass().getSimpleName()
|
||||
+ " does not fully implement ViewParent",
|
||||
e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performAccessibilityAction(View host, int action, Bundle args) {
|
||||
if (action == AccessibilityNodeInfo.ACTION_CLICK) {
|
||||
@@ -572,25 +539,6 @@ public class ReactEditText extends AppCompatEditText
|
||||
return ++mNativeEventCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to set an accessibility error or fail silently. EventCounter is the same one used as
|
||||
* with text.
|
||||
*
|
||||
* @param eventCounter
|
||||
* @param accessibilityErrorMessage
|
||||
*/
|
||||
public void maybeSetAccessibilityError(
|
||||
int eventCounter, @Nullable String accessibilityErrorMessage) {
|
||||
String previousScreenreaderError = (String) getTag(R.id.accessibility_error_message);
|
||||
if (!canUpdateWithEventCount(eventCounter)
|
||||
|| previousScreenreaderError == accessibilityErrorMessage) {
|
||||
return;
|
||||
}
|
||||
|
||||
setTag(R.id.accessibility_error_message, accessibilityErrorMessage);
|
||||
sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
|
||||
}
|
||||
|
||||
public void maybeSetTextFromJS(ReactTextUpdate reactTextUpdate) {
|
||||
mIsSettingTextFromJS = true;
|
||||
maybeSetText(reactTextUpdate);
|
||||
|
||||
+3
-17
@@ -384,7 +384,6 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
|
||||
|
||||
view.maybeSetTextFromState(update);
|
||||
view.maybeSetSelection(update.getJsEventCounter(), selectionStart, selectionEnd);
|
||||
view.maybeSetAccessibilityError(update.getJsEventCounter(), update.getScreenreaderError());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1339,12 +1338,6 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
|
||||
int currentJustificationMode =
|
||||
Build.VERSION.SDK_INT < Build.VERSION_CODES.O ? 0 : view.getJustificationMode();
|
||||
|
||||
@Nullable
|
||||
String accessibilityErrorMessage =
|
||||
props.hasKey("accessibilityErrorMessage")
|
||||
? props.getString("accessibilityErrorMessage")
|
||||
: null;
|
||||
|
||||
return ReactTextUpdate.buildReactTextUpdateFromState(
|
||||
spanned,
|
||||
state.getInt("mostRecentEventCount"),
|
||||
@@ -1352,8 +1345,7 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
|
||||
props, TextLayoutManager.isRTL(attributedString), view.getGravityHorizontal()),
|
||||
textBreakStrategy,
|
||||
TextAttributeProps.getJustificationMode(props, currentJustificationMode),
|
||||
containsMultipleFragments,
|
||||
accessibilityErrorMessage);
|
||||
containsMultipleFragments);
|
||||
}
|
||||
|
||||
public Object getReactTextUpdate(ReactEditText view, ReactStylesDiffMap props, MapBuffer state) {
|
||||
@@ -1373,6 +1365,7 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
|
||||
Spannable spanned =
|
||||
TextLayoutManagerMapBuffer.getOrCreateSpannableForText(
|
||||
view.getContext(), attributedString, mReactTextViewManagerCallback);
|
||||
|
||||
boolean containsMultipleFragments =
|
||||
attributedString.getMapBuffer(TextLayoutManagerMapBuffer.AS_KEY_FRAGMENTS).getCount() > 1;
|
||||
|
||||
@@ -1382,12 +1375,6 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
|
||||
int currentJustificationMode =
|
||||
Build.VERSION.SDK_INT < Build.VERSION_CODES.O ? 0 : view.getJustificationMode();
|
||||
|
||||
@Nullable
|
||||
String accessibilityErrorMessage =
|
||||
props.hasKey("accessibilityErrorMessage")
|
||||
? props.getString("accessibilityErrorMessage")
|
||||
: null;
|
||||
|
||||
return ReactTextUpdate.buildReactTextUpdateFromState(
|
||||
spanned,
|
||||
state.getInt(TX_STATE_KEY_MOST_RECENT_EVENT_COUNT),
|
||||
@@ -1395,7 +1382,6 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
|
||||
props, TextLayoutManagerMapBuffer.isRTL(attributedString), view.getGravityHorizontal()),
|
||||
textBreakStrategy,
|
||||
TextAttributeProps.getJustificationMode(props, currentJustificationMode),
|
||||
containsMultipleFragments,
|
||||
accessibilityErrorMessage);
|
||||
containsMultipleFragments);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-11
@@ -46,15 +46,11 @@ public class ReactTextInputShadowNode extends ReactBaseTextShadowNode
|
||||
@VisibleForTesting public static final String PROP_PLACEHOLDER = "placeholder";
|
||||
@VisibleForTesting public static final String PROP_SELECTION = "selection";
|
||||
|
||||
@VisibleForTesting
|
||||
public static final String PROP_ACCESSIBILITY_ERROR_MESSAGE = "accessibilityErrorMessage";
|
||||
|
||||
// Represents the {@code text} property only, not possible nested content.
|
||||
private @Nullable String mText = null;
|
||||
private @Nullable String mPlaceholder = null;
|
||||
private int mSelectionStart = UNSET;
|
||||
private int mSelectionEnd = UNSET;
|
||||
private @Nullable String mAccessibilityErrorMessage = null;
|
||||
|
||||
public ReactTextInputShadowNode(
|
||||
@Nullable ReactTextViewManagerCallback reactTextViewManagerCallback) {
|
||||
@@ -198,11 +194,6 @@ public class ReactTextInputShadowNode extends ReactBaseTextShadowNode
|
||||
return mPlaceholder;
|
||||
}
|
||||
|
||||
@ReactProp(name = PROP_ACCESSIBILITY_ERROR_MESSAGE)
|
||||
public void setScreenreaderError(String accessibilityErrorMessage) {
|
||||
mAccessibilityErrorMessage = accessibilityErrorMessage;
|
||||
}
|
||||
|
||||
@ReactProp(name = PROP_SELECTION)
|
||||
public void setSelection(@Nullable ReadableMap selection) {
|
||||
mSelectionStart = mSelectionEnd = UNSET;
|
||||
@@ -256,8 +247,7 @@ public class ReactTextInputShadowNode extends ReactBaseTextShadowNode
|
||||
mTextBreakStrategy,
|
||||
mJustificationMode,
|
||||
mSelectionStart,
|
||||
mSelectionEnd,
|
||||
mAccessibilityErrorMessage);
|
||||
mSelectionEnd);
|
||||
uiViewOperationQueue.enqueueUpdateExtraData(getReactTag(), reactTextUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,10 +39,7 @@
|
||||
<!-- tag is used to store accessibilityLinks tag -->
|
||||
<item type="id" name="accessibility_links"/>
|
||||
|
||||
<!--tag is used to store accessibilityErrorMessage tag to announce TextInput errors -->
|
||||
<item type="id" name="accessibility_error_message"/>
|
||||
|
||||
<!--tag is used to store accessibilityLabelledBy tag -->
|
||||
<!-- tag is used to store accessibilityLabelledBy tag -->
|
||||
<item type="id" name="labelled_by"/>
|
||||
|
||||
<!-- tag is used store bitset of pointer events observed -->
|
||||
|
||||
-5
@@ -68,10 +68,6 @@ AndroidTextInputProps::AndroidTextInputProps(
|
||||
"underlineColorAndroid",
|
||||
sourceProps.underlineColorAndroid,
|
||||
{})),
|
||||
accessibilityErrorMessage(convertRawProp(context, rawProps,
|
||||
"accessibilityErrorMessage",
|
||||
sourceProps.accessibilityErrorMessage,
|
||||
{})),
|
||||
inlineImageLeft(CoreFeatures::enablePropIteratorSetter? sourceProps.inlineImageLeft : convertRawProp(context, rawProps,
|
||||
"inlineImageLeft",
|
||||
sourceProps.inlineImageLeft,
|
||||
@@ -435,7 +431,6 @@ folly::dynamic AndroidTextInputProps::getDynamic() const {
|
||||
props["disableFullscreenUI"] = disableFullscreenUI;
|
||||
props["textBreakStrategy"] = textBreakStrategy;
|
||||
props["underlineColorAndroid"] = toAndroidRepr(underlineColorAndroid);
|
||||
props["accessibilityErrorMessage"] = accessibilityErrorMessage;
|
||||
props["inlineImageLeft"] = inlineImageLeft;
|
||||
props["inlineImagePadding"] = inlineImagePadding;
|
||||
props["importantForAutofill"] = importantForAutofill;
|
||||
|
||||
-1
@@ -120,7 +120,6 @@ class AndroidTextInputProps final : public ViewProps, public BaseTextProps {
|
||||
bool disableFullscreenUI{false};
|
||||
std::string textBreakStrategy{};
|
||||
SharedColor underlineColorAndroid{};
|
||||
std::string accessibilityErrorMessage{};
|
||||
std::string inlineImageLeft{};
|
||||
int inlineImagePadding{0};
|
||||
std::string importantForAutofill{};
|
||||
|
||||
@@ -1544,88 +1544,9 @@ function DisplayOptionStatusExample({
|
||||
);
|
||||
}
|
||||
|
||||
function AccessibilityErrorWithButtons(): React.Node {
|
||||
const [text, setText] = React.useState('');
|
||||
const [error, setError] = React.useState<?string>(null);
|
||||
const [accessibilityInvalid, setAccessibilityInvalid] = React.useState(false);
|
||||
return (
|
||||
<View>
|
||||
<RNTesterBlock>
|
||||
<TextInput
|
||||
accessibilityErrorMessage={error}
|
||||
accessibilityInvalid={accessibilityInvalid}
|
||||
onChangeText={newText => {
|
||||
setText(newText);
|
||||
if (newText === 'Error') {
|
||||
setError('the newText is: ' + newText);
|
||||
setAccessibilityInvalid(true);
|
||||
} else {
|
||||
setError(null);
|
||||
setAccessibilityInvalid(false);
|
||||
}
|
||||
}}
|
||||
value={text}
|
||||
style={styles.default}
|
||||
/>
|
||||
<Button
|
||||
onPress={() => {
|
||||
setError('This error is set with Button onPress callback');
|
||||
}}
|
||||
title="Press to set an accessibilityErrorMessage to a non-empty value"
|
||||
/>
|
||||
<Button
|
||||
onPress={() => setAccessibilityInvalid(!accessibilityInvalid)}
|
||||
title={`Press to set accessibilityInvalid to ${
|
||||
accessibilityInvalid ? 'false' : 'true'
|
||||
}`}
|
||||
/>
|
||||
<Button
|
||||
onPress={() => setError('')}
|
||||
title={'Press to set an empty error message'}
|
||||
/>
|
||||
</RNTesterBlock>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
function AccessibilityErrorDoesNotClear(): React.Node {
|
||||
const [text, setText] = React.useState('');
|
||||
const [error, setError] = React.useState('');
|
||||
const [accessibilityInvalid, setAccessibilityInvalid] = React.useState(false);
|
||||
return (
|
||||
<View>
|
||||
<RNTesterBlock title="TextView without label">
|
||||
<Text>Set an error, change textinput value and then announce it.</Text>
|
||||
<TextInput
|
||||
accessibilityErrorMessage={error}
|
||||
accessibilityInvalid={accessibilityInvalid}
|
||||
value={text}
|
||||
onChangeText={newText => setText(newText)}
|
||||
style={styles.default}
|
||||
/>
|
||||
<Text>
|
||||
The value of the accessibilityErrorMessage prop is{' '}
|
||||
{error.length > 0 ? error : 'empty error'}
|
||||
</Text>
|
||||
<Button
|
||||
onPress={() => {
|
||||
setError('This is an error');
|
||||
}}
|
||||
title="sets accessibilityErrorMessage to 'This is an error'"
|
||||
/>
|
||||
<Button
|
||||
onPress={() => setAccessibilityInvalid(!accessibilityInvalid)}
|
||||
title={`Press to set accessibilityInvalid to ${
|
||||
accessibilityInvalid ? 'false' : 'true'
|
||||
}`}
|
||||
/>
|
||||
</RNTesterBlock>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
function AccessibilityExpandedExample(): React.Node {
|
||||
const [expand, setExpanded] = React.useState(false);
|
||||
const [pressed, setPressed] = React.useState(false);
|
||||
const expandAction = {name: 'expand'};
|
||||
const collapseAction = {name: 'collapse'};
|
||||
return (
|
||||
@@ -1766,18 +1687,6 @@ exports.examples = [
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'accessibilityErrorMessage onChangeText or Button onPress',
|
||||
render: function (): React.Node {
|
||||
return <AccessibilityErrorWithButtons />;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'accessibilityErrorMessage does not clear with text change',
|
||||
render: function (): React.Node {
|
||||
return <AccessibilityErrorDoesNotClear />;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'TextInput with aria-labelledby attribute"',
|
||||
render(): React.Element<typeof View> {
|
||||
|
||||
Reference in New Issue
Block a user