Skip to content

Commit af2c26a

Browse files
committed
Fix TextInput onEndEditing & onSubmitEditing signature & doc
1 parent 0585050 commit af2c26a

3 files changed

Lines changed: 128 additions & 134 deletions

File tree

‎lib/js/src/components/textInput.js‎

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/components/textInput.re‎

Lines changed: 98 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ external view: ReasonReact.reactClass = "TextInput";
99

1010
[@bs.send] external blur: ReasonReact.reactRef => unit = "";
1111

12+
type editingEvent = {
13+
.
14+
"nativeEvent": {
15+
.
16+
"text": string,
17+
"eventCount": int,
18+
"target": int,
19+
},
20+
};
21+
1222
let make =
1323
(
1424
~accessibilityLabel=?,
@@ -47,14 +57,14 @@ let make =
4757
~maxLength=?,
4858
~multiline=?,
4959
~onBlur=?,
50-
~onChange=?,
5160
~onChangeText=?,
52-
~onContentSizeChange=?,
61+
~onChange=?,
5362
~onEndEditing=?,
63+
~onSubmitEditing=?,
64+
~onContentSizeChange=?,
5465
~onFocus=?,
5566
~onScroll=?,
5667
~onSelectionChange=?,
57-
~onSubmitEditing=?,
5868
~placeholder=?,
5969
~placeholderTextColor=?,
6070
~returnKeyType=?,
@@ -86,86 +96,82 @@ let make =
8696
ViewProps.extend(
8797
{
8898
"autoCapitalize":
89-
autoCapitalize
90-
->Belt.Option.map(
91-
fun
92-
| `none => "none"
93-
| `sentences => "sentences"
94-
| `words => "words"
95-
| `characters => "characters",
96-
),
99+
autoCapitalize->Belt.Option.map(
100+
fun
101+
| `none => "none"
102+
| `sentences => "sentences"
103+
| `words => "words"
104+
| `characters => "characters",
105+
),
97106
"autoComplete":
98-
autoComplete
99-
->Belt.Option.map(
100-
fun
101-
| `off => "off"
102-
| `username => "username"
103-
| `password => "password"
104-
| `email => "email"
105-
| `name => "name"
106-
| `tel => "tel"
107-
| `streetAddress => "street-address"
108-
| `postalCode => "postal-code"
109-
| `ccNumber => "cc-number"
110-
| `ccCsc => "cc-csc"
111-
| `ccExp => "cc-exp"
112-
| `ccExpMonth => "cc-exp-month"
113-
| `ccExpYear => "cc-exp-year",
114-
),
107+
autoComplete->Belt.Option.map(
108+
fun
109+
| `off => "off"
110+
| `username => "username"
111+
| `password => "password"
112+
| `email => "email"
113+
| `name => "name"
114+
| `tel => "tel"
115+
| `streetAddress => "street-address"
116+
| `postalCode => "postal-code"
117+
| `ccNumber => "cc-number"
118+
| `ccCsc => "cc-csc"
119+
| `ccExp => "cc-exp"
120+
| `ccExpMonth => "cc-exp-month"
121+
| `ccExpYear => "cc-exp-year",
122+
),
115123
"autoCorrect": autoCorrect,
116124
"autoFocus": autoFocus,
117125
"blurOnSubmit": blurOnSubmit,
118126
"caretHidden": caretHidden,
119127
"defaultValue": defaultValue,
120128
"editable": editable,
121129
"keyboardType":
122-
keyboardType
123-
->Belt.Option.map(
124-
fun
125-
| `default => "default"
126-
| `emailAddress => "email-address"
127-
| `numeric => "numeric"
128-
| `phonePad => "phone-pad"
129-
| `asciiCapable => "ascii-capable"
130-
| `numbersAndPunctuation => "numbers-and-punctuation"
131-
| `url => "url"
132-
| `numberPad => "number-pad"
133-
| `namePhonePad => "name-phone-pad"
134-
| `decimalPad => "decimal-pad"
135-
| `twitter => "twitter"
136-
| `webSearch => "web-search",
137-
),
130+
keyboardType->Belt.Option.map(
131+
fun
132+
| `default => "default"
133+
| `emailAddress => "email-address"
134+
| `numeric => "numeric"
135+
| `phonePad => "phone-pad"
136+
| `asciiCapable => "ascii-capable"
137+
| `numbersAndPunctuation => "numbers-and-punctuation"
138+
| `url => "url"
139+
| `numberPad => "number-pad"
140+
| `namePhonePad => "name-phone-pad"
141+
| `decimalPad => "decimal-pad"
142+
| `twitter => "twitter"
143+
| `webSearch => "web-search",
144+
),
138145
"maxLength": maxLength,
139146
"multiline": multiline,
140147
"onBlur": onBlur,
141-
"onChange": onChange,
142148
"onChangeText": onChangeText,
143-
"onContentSizeChange": onContentSizeChange,
149+
"onChange": onChange,
144150
"onEndEditing": onEndEditing,
151+
"onSubmitEditing": onSubmitEditing,
152+
"onContentSizeChange": onContentSizeChange,
145153
"onFocus": onFocus,
146154
"onScroll": onScroll,
147155
"onSelectionChange": onSelectionChange,
148-
"onSubmitEditing": onSubmitEditing,
149156
"placeholder": placeholder,
150157
"placeholderTextColor": placeholderTextColor,
151158
"returnKeyType":
152-
returnKeyType
153-
->Belt.Option.map(
154-
fun
155-
| `done_ => "done"
156-
| `go => "go"
157-
| `next => "next"
158-
| `search => "search"
159-
| `send => "send"
160-
| `none => "none"
161-
| `previous => "previous"
162-
| `default => "default"
163-
| `emergencyCall => "emergencyCall"
164-
| `google => "google"
165-
| `join => "join"
166-
| `route => "route"
167-
| `yahoo => "yahoo",
168-
),
159+
returnKeyType->Belt.Option.map(
160+
fun
161+
| `done_ => "done"
162+
| `go => "go"
163+
| `next => "next"
164+
| `search => "search"
165+
| `send => "send"
166+
| `none => "none"
167+
| `previous => "previous"
168+
| `default => "default"
169+
| `emergencyCall => "emergencyCall"
170+
| `google => "google"
171+
| `join => "join"
172+
| `route => "route"
173+
| `yahoo => "yahoo",
174+
),
169175
"secureTextEntry": secureTextEntry,
170176
"selectTextOnFocus": selectTextOnFocus,
171177
"selection": selection,
@@ -178,45 +184,41 @@ let make =
178184
"numberOfLines": numberOfLines,
179185
"returnKeyLabel": returnKeyLabel,
180186
"textBreakStrategy":
181-
textBreakStrategy
182-
->Belt.Option.map(
183-
fun
184-
| `simple => "simple"
185-
| `highQuality => "highQuality"
186-
| `balanced => "balanced",
187-
),
187+
textBreakStrategy->Belt.Option.map(
188+
fun
189+
| `simple => "simple"
190+
| `highQuality => "highQuality"
191+
| `balanced => "balanced",
192+
),
188193
"underlineColorAndroid": underlineColorAndroid,
189194
"clearButtonMode":
190-
clearButtonMode
191-
->Belt.Option.map(
192-
fun
193-
| `never => "never"
194-
| `whileEditing => "while-editing"
195-
| `unlessEditing => "unless-editing"
196-
| `always => "always",
197-
),
195+
clearButtonMode->Belt.Option.map(
196+
fun
197+
| `never => "never"
198+
| `whileEditing => "while-editing"
199+
| `unlessEditing => "unless-editing"
200+
| `always => "always",
201+
),
198202
"clearTextOnFocus": clearTextOnFocus,
199203
"dataDetectorTypes":
200-
dataDetectorTypes
201-
->Belt.Option.map(
202-
Array.map(
203-
fun
204-
| `phoneNumber => "phoneNumber"
205-
| `link => "link"
206-
| `calendarEvent => "calendarEvent"
207-
| `none => "none"
208-
| `all => "all",
209-
),
204+
dataDetectorTypes->Belt.Option.map(
205+
Array.map(
206+
fun
207+
| `phoneNumber => "phoneNumber"
208+
| `link => "link"
209+
| `calendarEvent => "calendarEvent"
210+
| `none => "none"
211+
| `all => "all",
210212
),
213+
),
211214
"enablesReturnKeyAutomatically": enablesReturnKeyAutomatically,
212215
"keyboardAppearance":
213-
keyboardAppearance
214-
->Belt.Option.map(
215-
fun
216-
| `default => "never"
217-
| `light => "light"
218-
| `dark => "dark",
219-
),
216+
keyboardAppearance->Belt.Option.map(
217+
fun
218+
| `default => "never"
219+
| `light => "light"
220+
| `dark => "dark",
221+
),
220222
"onKeyPress": onKeyPress,
221223
"selectionState": selectionState,
222224
"spellCheck": spellCheck,

‎src/components/textInput.rei‎

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,23 @@ You can read more on [Text] component usage in official docs: {{:https://faceboo
8787
{[
8888
~onBlur: unit => unit=?
8989
]}
90+
{4 onChangeText}
91+
{[
92+
~onChangeText: string => unit=?
93+
]}
9094
{4 onChange}
9195
{[
92-
~onChange: unit => unit=?
96+
~onChange: editingEvent => unit=?
9397
]}
94-
{4 onChangeText}
98+
{4 onEndEditing}
9599
{[
96-
~onChangeText: string => unit=?
100+
~onEndEditing: editingEvent => unit=?
97101
]}
102+
{4 onSubmitEditing}
103+
{[
104+
~onSubmitEditing: editingEvent => unit=?
105+
]}
106+
98107
{4 onContentSizeChange}
99108
{[
100109
~onContentSizeChange: {
@@ -109,10 +118,6 @@ You can read more on [Text] component usage in official docs: {{:https://faceboo
109118
}
110119
} => unit=?
111120
]}
112-
{4 onEndEditing}
113-
{[
114-
~onEndEditing: unit => unit=?
115-
]}
116121
{4 onFocus}
117122
{[
118123
~onFocus: unit => unit=?
@@ -145,10 +150,6 @@ You can read more on [Text] component usage in official docs: {{:https://faceboo
145150
}
146151
} => unit=?
147152
]}
148-
{4 onSubmitEditing}
149-
{[
150-
~onSubmitEditing: unit => unit=?
151-
]}
152153
{4 placeholder}
153154
{[
154155
~placeholder: string=?
@@ -295,6 +296,16 @@ You can read more on [Text] component usage in official docs: {{:https://faceboo
295296
Returns [true] if the input is currently focused; [false] otherwise.
296297
*/
297298

299+
type editingEvent = {
300+
.
301+
"nativeEvent": {
302+
.
303+
"text": string,
304+
"eventCount": int,
305+
"target": int,
306+
},
307+
};
308+
298309
let make:
299310
(
300311
~accessibilityLabel: ReasonReact.reactElement=?,
@@ -369,18 +380,10 @@ let make:
369380
~maxLength: int=?,
370381
~multiline: bool=?,
371382
~onBlur: unit => unit=?,
372-
~onChange: {
373-
.
374-
"nativeEvent": {
375-
.
376-
"text": string,
377-
"target": int,
378-
"eventCount": int,
379-
},
380-
} =>
381-
unit
382-
=?,
383383
~onChangeText: string => unit=?,
384+
~onChange: editingEvent => unit=?,
385+
~onEndEditing: editingEvent => unit=?,
386+
~onSubmitEditing: editingEvent => unit=?,
384387
~onContentSizeChange: {
385388
.
386389
"nativeEvent": {
@@ -394,16 +397,6 @@ let make:
394397
} =>
395398
unit
396399
=?,
397-
~onEndEditing: {
398-
.
399-
"nativeEvent": {
400-
.
401-
"text": string,
402-
"target": int,
403-
},
404-
} =>
405-
unit
406-
=?,
407400
~onFocus: unit => unit=?,
408401
~onScroll: {
409402
.
@@ -431,7 +424,6 @@ let make:
431424
} =>
432425
unit
433426
=?,
434-
~onSubmitEditing: unit => unit=?,
435427
~placeholder: string=?,
436428
~placeholderTextColor: string=?,
437429
~returnKeyType: [
@@ -513,4 +505,4 @@ blur [TextInput] programmatically
513505

514506
let focus: ReasonReact.reactRef => unit;
515507

516-
let blur: ReasonReact.reactRef => unit;
508+
let blur: ReasonReact.reactRef => unit;

0 commit comments

Comments
 (0)