Skip to content

Commit 5062553

Browse files
tarunrajputfacebook-github-bot
authored andcommitted
Add enterKeyHint in TextInput type declaration (#37624)
Summary: Resolves: #37622 Related: #34482 https://reactnative.dev/docs/textinput#enterkeyhint ## Changelog: <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [Internal][Added]: Add enterKeyHint in TextInput type declaration Pull Request resolved: #37624 Reviewed By: cortinico, NickGerleman Differential Revision: D46292040 Pulled By: lunaleaps fbshipit-source-id: a037b7f8dd0d60880dcf1aec64749546fa54a95d
1 parent 46d14ce commit 5062553

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

packages/react-native/Libraries/Components/TextInput/TextInput.d.ts

+15
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ export type ReturnKeyTypeOptions =
7070
| ReturnKeyTypeAndroid
7171
| ReturnKeyTypeIOS;
7272

73+
export type EnterKeyHintTypeAndroid = 'previous';
74+
export type EnterKeyHintTypeIOS = 'enter';
75+
export type EnterKeyHintType = 'done' | 'go' | 'next' | 'search' | 'send';
76+
77+
export type EnterKeyHintTypeOptions =
78+
| EnterKeyHintType
79+
| EnterKeyHintTypeAndroid
80+
| EnterKeyHintTypeIOS;
81+
7382
type DataDetectorTypes =
7483
| 'phoneNumber'
7584
| 'link'
@@ -779,6 +788,12 @@ export interface TextInputProps
779788
*/
780789
returnKeyType?: ReturnKeyTypeOptions | undefined;
781790

791+
/**
792+
* Determines what text should be shown to the return key on virtual keyboards.
793+
* Has precedence over the returnKeyType prop.
794+
*/
795+
enterKeyHint?: EnterKeyHintTypeOptions | undefined;
796+
782797
/**
783798
* If true, the text input obscures the text entered so that sensitive text like passwords stay secure.
784799
* The default value is false.

packages/react-native/Libraries/Components/TextInput/TextInput.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,16 @@ export type TextContentType =
223223
| 'oneTimeCode';
224224

225225
export type enterKeyHintType =
226-
| 'enter'
226+
// Cross Platform
227227
| 'done'
228228
| 'go'
229229
| 'next'
230-
| 'previous'
231230
| 'search'
232-
| 'send';
231+
| 'send'
232+
// Android-only
233+
| 'previous'
234+
// iOS-only
235+
| 'enter';
233236

234237
type PasswordRules = string;
235238

0 commit comments

Comments
 (0)