From 5062553c62ea743e7579ef57aceeec8636121c99 Mon Sep 17 00:00:00 2001 From: tarunrajput Date: Mon, 5 Jun 2023 13:08:05 -0700 Subject: [PATCH] Add enterKeyHint in TextInput type declaration (#37624) Summary: Resolves: https://github.com/facebook/react-native/issues/37622 Related: https://github.com/facebook/react-native/pull/34482 https://reactnative.dev/docs/textinput#enterkeyhint ## Changelog: [Internal][Added]: Add enterKeyHint in TextInput type declaration Pull Request resolved: https://github.com/facebook/react-native/pull/37624 Reviewed By: cortinico, NickGerleman Differential Revision: D46292040 Pulled By: lunaleaps fbshipit-source-id: a037b7f8dd0d60880dcf1aec64749546fa54a95d --- .../Libraries/Components/TextInput/TextInput.d.ts | 15 +++++++++++++++ .../Libraries/Components/TextInput/TextInput.js | 9 ++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/packages/react-native/Libraries/Components/TextInput/TextInput.d.ts b/packages/react-native/Libraries/Components/TextInput/TextInput.d.ts index ff029fb29b5f8c..8badb2a9d39de5 100644 --- a/packages/react-native/Libraries/Components/TextInput/TextInput.d.ts +++ b/packages/react-native/Libraries/Components/TextInput/TextInput.d.ts @@ -70,6 +70,15 @@ export type ReturnKeyTypeOptions = | ReturnKeyTypeAndroid | ReturnKeyTypeIOS; +export type EnterKeyHintTypeAndroid = 'previous'; +export type EnterKeyHintTypeIOS = 'enter'; +export type EnterKeyHintType = 'done' | 'go' | 'next' | 'search' | 'send'; + +export type EnterKeyHintTypeOptions = + | EnterKeyHintType + | EnterKeyHintTypeAndroid + | EnterKeyHintTypeIOS; + type DataDetectorTypes = | 'phoneNumber' | 'link' @@ -779,6 +788,12 @@ export interface TextInputProps */ returnKeyType?: ReturnKeyTypeOptions | undefined; + /** + * Determines what text should be shown to the return key on virtual keyboards. + * Has precedence over the returnKeyType prop. + */ + enterKeyHint?: EnterKeyHintTypeOptions | undefined; + /** * If true, the text input obscures the text entered so that sensitive text like passwords stay secure. * The default value is false. diff --git a/packages/react-native/Libraries/Components/TextInput/TextInput.js b/packages/react-native/Libraries/Components/TextInput/TextInput.js index df890974ece66c..67ad18c0c19b42 100644 --- a/packages/react-native/Libraries/Components/TextInput/TextInput.js +++ b/packages/react-native/Libraries/Components/TextInput/TextInput.js @@ -223,13 +223,16 @@ export type TextContentType = | 'oneTimeCode'; export type enterKeyHintType = - | 'enter' + // Cross Platform | 'done' | 'go' | 'next' - | 'previous' | 'search' - | 'send'; + | 'send' + // Android-only + | 'previous' + // iOS-only + | 'enter'; type PasswordRules = string;