Skip to content

Commit

Permalink
draft implementation of android_errorMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
fabOnReact committed Mar 12, 2022
1 parent a4ef7a7 commit 60b6c9b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
9 changes: 8 additions & 1 deletion Libraries/Components/TextInput/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,14 @@ type AndroidProps = $ReadOnly<{|
*/
disableFullscreenUI?: ?boolean,

/**
* String to be read by screenreaders to indicate an error state. If this value is
* not null, an error will be announced. You can use onChangeText or onBlur to
* detect an error and set this prop. Once the error is gone, set this to null
* to clear the error
*/
android_errorMessage?: ?Stringish,

importantForAutofill?: ?(
| 'auto'
| 'no'
Expand Down Expand Up @@ -1281,7 +1289,6 @@ function InternalTextInput(props: Props): React.Node {
* match up exactly with the props for TextInput. This will need to get
* fixed */
<AndroidTextInput
error="Fabrizio! Why did you make a mistake?
ref={_setNativeRef}
{...props}
{...eventHandlers}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public class ViewProps {
public static final String BACKGROUND_COLOR = "backgroundColor";
public static final String FOREGROUND_COLOR = "foregroundColor";
public static final String COLOR = "color";
public static final String ERROR = "error";
public static final String ERROR_MESSAGE = "error";
public static final String FONT_SIZE = "fontSize";
public static final String FONT_WEIGHT = "fontWeight";
public static final String FONT_STYLE = "fontStyle";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,8 @@ public void updateExtraData(ReactEditText view, Object extraData) {
}
}

@ReactProp(name = ViewProps.ERROR)
public void setError(ReactEditText view, String error) {
@ReactProp(name = ViewProps.ERROR_MESSAGE)
public void setAndroidErrorMessage(ReactEditText view, String error) {
if (error != null) {
view.setError(error);
}
Expand Down

0 comments on commit 60b6c9b

Please sign in to comment.