Skip to content

Commit 1d8b99f

Browse files
authored
feat: add submitBehavior and deprecate blurOnSubmit of TextInput component (facebook#4167)
1 parent ef9202d commit 1d8b99f

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

docs/textinput.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ If `true`, focuses the input on `componentDidMount` or `useEffect`. The default
241241

242242
### `blurOnSubmit`
243243

244+
> **Deprecated.** Note that `submitBehavior` now takes the place of `blurOnSubmit` and will override any behavior defined by `blurOnSubmit`. See [submitBehavior](textinput#submitbehavior)
245+
244246
If `true`, the text field will blur when submitted. The default value is true for single-line fields and false for multiline fields. Note that for multiline fields, setting `blurOnSubmit` to `true` means that pressing return will blur the field and trigger the `onSubmitEditing` event instead of inserting a newline into the field.
245247

246248
| Type |
@@ -865,6 +867,31 @@ If `false`, disables spell-check style (i.e. red underlines). The default value
865867

866868
---
867869

870+
### `submitBehavior`
871+
872+
When the return key is pressed,
873+
874+
For single line inputs:
875+
876+
- `'newline'` defaults to `'blurAndSubmit'`
877+
- `undefined` defaults to `'blurAndSubmit'`
878+
879+
For multiline inputs:
880+
881+
- `'newline'` adds a newline
882+
- `undefined` defaults to `'newline'`
883+
884+
For both single line and multiline inputs:
885+
886+
- `'submit'` will only send a submit event and not blur the input
887+
- `'blurAndSubmit`' will both blur the input and send a submit event
888+
889+
| Type |
890+
| ------------------------------------------ |
891+
| enum('submit', 'blurAndSubmit', 'newline') |
892+
893+
---
894+
868895
### `textAlign`
869896

870897
Align the input text to the left, center, or right sides of the input field.

0 commit comments

Comments
 (0)