Skip to content

Commit ebbade3

Browse files
comp615necolas
andcommitted
[fix] TextInput support for 'returnKeyType'
Close necolas#1413 Co-authored-by: Nicolas Gallagher <nicolasgallagher@gmail.com>
1 parent ef770d4 commit ebbade3

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

packages/react-native-web/src/exports/TextInput/__tests__/index-test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,12 @@ describe('components/TextInput', () => {
420420
});
421421
});
422422

423+
test('prop "returnKeyType"', () => {
424+
const returnKeyType = 'previous';
425+
const input = findNativeInput(shallow(<TextInput returnKeyType={returnKeyType} />));
426+
expect(input.prop('enterkeyhint')).toEqual(returnKeyType);
427+
});
428+
423429
test('prop "secureTextEntry"', () => {
424430
let input = findNativeInput(shallow(<TextInput secureTextEntry />));
425431
expect(input.prop('type')).toEqual('password');

packages/react-native-web/src/exports/TextInput/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ class TextInput extends Component<*> {
108108
onSubmitEditing: func,
109109
placeholder: string,
110110
placeholderTextColor: ColorPropType,
111+
returnKeyType: oneOf(['enter', 'done', 'go', 'next', 'previous', 'search', 'send']),
111112
secureTextEntry: bool,
112113
selectTextOnFocus: bool,
113114
selection: shape({
@@ -131,7 +132,6 @@ class TextInput extends Component<*> {
131132
onEndEditing: func,
132133
onScroll: func,
133134
returnKeyLabel: string,
134-
returnKeyType: string,
135135
selectionColor: ColorPropType,
136136
selectionState: any,
137137
textBreakStrategy: string,
@@ -179,6 +179,7 @@ class TextInput extends Component<*> {
179179
keyboardType,
180180
multiline,
181181
numberOfLines,
182+
returnKeyType,
182183
secureTextEntry,
183184
/* eslint-disable */
184185
blurOnSubmit,
@@ -213,7 +214,6 @@ class TextInput extends Component<*> {
213214
removeClippedSubviews,
214215
renderToHardwareTextureAndroid,
215216
returnKeyLabel,
216-
returnKeyType,
217217
scrollEnabled,
218218
selectionColor,
219219
selectionState,
@@ -262,6 +262,7 @@ class TextInput extends Component<*> {
262262
autoCorrect: autoCorrect ? 'on' : 'off',
263263
classList: [classes.textinput],
264264
dir: 'auto',
265+
enterkeyhint: returnKeyType,
265266
onBlur: normalizeEventHandler(this._handleBlur),
266267
onChange: normalizeEventHandler(this._handleChange),
267268
onFocus: normalizeEventHandler(this._handleFocus),

packages/react-native-web/src/modules/createDOMProps/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ const createDOMProps = (component, props, styleResolver) => {
182182
if (nativeID && nativeID.constructor === String) {
183183
domProps.id = nativeID;
184184
}
185+
185186
// Link security
186187
// https://mathiasbynens.github.io/rel-noopener/
187188
// Note: using "noreferrer" doesn't impact referrer tracking for https

packages/website/storybook/1-components/TextInput/TextInputScreen.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,12 @@ nativeEvent: { key: keyValue } }`}</Code>{' '}
279279
}}
280280
/>
281281

282+
<DocItem
283+
name="returnKeyType"
284+
typeInfo="?enum('enter', 'done', 'go', 'next', 'previous', 'search', 'send')"
285+
description="Specifies what action label (or icon) to present for the enter key on virtual keyboards. Maps to the enterkeyhint attribute on web."
286+
/>
287+
282288
<DocItem
283289
name="secureTextEntry"
284290
typeInfo="?boolean = false"

0 commit comments

Comments
 (0)