Skip to content

Commit

Permalink
TextInput: Default blurOnSubmit in JS
Browse files Browse the repository at this point in the history
Summary:
Consolidates the logic for the default value of `blurOnSubmit` on `TextInput` in the JavaScript component.

This only materially impacts Fabric.

Changelog:
[Internal]

Reviewed By: mdvacca

Differential Revision: D21491482

fbshipit-source-id: 16d8aba32e7d0321a4583e87e03405ea587e35d4
  • Loading branch information
yungsters authored and facebook-github-bot committed May 10, 2020
1 parent aece57b commit a1ac251
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Libraries/Components/TextInput/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,10 @@ function InternalTextInput(props: Props): React.Node {
// This is a hack to let Flow know we want an exact object
|} = {...null};
// The default value for `blurOnSubmit` is true for single-line fields and
// false for multi-line fields.
const blurOnSubmit = props.blurOnSubmit ?? !props.multiline;
if (Platform.OS === 'ios') {
const RCTTextInputView = props.multiline
? RCTMultilineTextInputView
Expand All @@ -1073,6 +1077,7 @@ function InternalTextInput(props: Props): React.Node {
<RCTTextInputView
ref={_setNativeRef}
{...props}
blurOnSubmit={blurOnSubmit}
dataDetectorTypes={props.dataDetectorTypes}
mostRecentEventCount={mostRecentEventCount}
onBlur={_onBlur}
Expand Down Expand Up @@ -1108,6 +1113,7 @@ function InternalTextInput(props: Props): React.Node {
ref={_setNativeRef}
{...props}
autoCapitalize={autoCapitalize}
blurOnSubmit={blurOnSubmit}
children={children}
disableFullscreenUI={props.disableFullscreenUI}
mostRecentEventCount={mostRecentEventCount}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ exports[`TextInput tests should render as expected: should deep render when mock
<RCTSinglelineTextInputView
accessible={true}
allowFontScaling={true}
blurOnSubmit={true}
focusable={true}
forwardedRef={null}
mostRecentEventCount={0}
Expand Down Expand Up @@ -31,6 +32,7 @@ exports[`TextInput tests should render as expected: should deep render when not
<RCTSinglelineTextInputView
accessible={true}
allowFontScaling={true}
blurOnSubmit={true}
focusable={true}
forwardedRef={null}
mostRecentEventCount={0}
Expand Down

0 comments on commit a1ac251

Please sign in to comment.