Skip to content

Commit

Permalink
Fix linting and test
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony Du committed Apr 19, 2022
1 parent f3f759f commit 716cbfd
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export type ReturnKeyType =
| 'route'
| 'yahoo';

export type ReturnKeyAction = 'submit' | 'blurAndSubmit' | 'newline';
export type ReturnKeyAction = 'submit' | 'blurAndSubmit' | 'newline';

export type NativeProps = $ReadOnly<{|
// This allows us to inherit everything from ViewProps except for style (see below)
Expand Down Expand Up @@ -548,7 +548,7 @@ export type NativeProps = $ReadOnly<{|
* - `'submit'` will only send a submit event and not blur the input
* - `'blurAndSubmit`' will both blur the input and send a submit event
*/
returnKeyAction?: ?ReturnKeyAction;
returnKeyAction?: ?ReturnKeyAction,

/**
* Note that not all Text styles are supported, an incomplete list of what is not supported includes:
Expand Down
22 changes: 11 additions & 11 deletions Libraries/Components/TextInput/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export type ReturnKeyType =
| 'route'
| 'yahoo';

export type ReturnKeyAction = 'submit' | 'blurAndSubmit' | 'newline';
export type ReturnKeyAction = 'submit' | 'blurAndSubmit' | 'newline';

export type AutoCapitalize = 'none' | 'sentences' | 'words' | 'characters';

Expand Down Expand Up @@ -792,7 +792,7 @@ export type Props = $ReadOnly<{|
* - `'submit'` will only send a submit event and not blur the input
* - `'blurAndSubmit`' will both blur the input and send a submit event
*/
returnKeyAction?: ?ReturnKeyAction;
returnKeyAction?: ?ReturnKeyAction,

/**
* Note that not all Text styles are supported, an incomplete list of what is not supported includes:
Expand Down Expand Up @@ -1204,29 +1204,29 @@ function InternalTextInput(props: Props): React.Node {

let textInput = null;

const multiline = props.multiline ?? false;

let returnKeyAction: ReturnKeyAction;
if (props.returnKeyAction) {
if (props.returnKeyAction != null) {
// `returnKeyAction` is set explicitly
if (!props.multiline && returnKeyAction === 'newline') {
if (!multiline && props.returnKeyAction === 'newline') {
// For single line text inputs, `'newline'` is not a valid option
returnKeyAction = 'blurAndSubmit';
} else {
returnKeyAction = props.returnKeyAction;
}
} else if (props.multiline) {
if (props.blurOnSubmit) {
} else if (multiline) {
if (props.blurOnSubmit === true) {
returnKeyAction = 'blurAndSubmit';
} else {
returnKeyAction = 'newline';
}
} else {
// Single line
if (props.blurOnSubmit) {
returnKeyAction = 'blurAndSubmit'
} else if (props.blurOnSubmit === false) {
returnKeyAction = 'submit';
} else {
if (props.blurOnSubmit !== false) {
returnKeyAction = 'blurAndSubmit';
} else {
returnKeyAction = 'submit';
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ public void run() {

private void fireEditorActionAndCheckRecording(
final ReactEditText reactEditText, final int actionId) throws Throwable {
fireEditorActionAndCheckRecording(reactEditText, actionId, true);
fireEditorActionAndCheckRecording(reactEditText, actionId, false);
fireEditorActionAndCheckRecording(reactEditText, actionId, "blurAndSubmit");
fireEditorActionAndCheckRecording(reactEditText, actionId, "newline");
}

private void fireEditorActionAndCheckRecording(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,7 @@ class ReturnKeyActionExample extends React.Component<{...}> {
placeholder="multiline newline"
returnKeyAction="newline"
/>
<TextInput
ref={this.ref11}
multiline
placeholder="multiline default"
/>
<TextInput ref={this.ref11} multiline placeholder="multiline default" />
</View>
);
}
Expand Down

0 comments on commit 716cbfd

Please sign in to comment.