You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Summary
Fixes: #295
- This PR solves this issue
#295;
- This PR adds new props such as **returnKeyType**, **submitBehavior**,
**onSubmitEditing**, **returnKeyLabel** (Android only);
- For the implementation I took most of the code from the original
**TextInput** component of react-native;
- This PR impacts the main files with the implementation of text input.
## Test Plan
To verify that the props work set the corresponding props on the text
input and see how they work.
Note that **returnKeyLabel** is visible only in landscape mode.
## Screenshots / Videos
Custom **returnKeyLabel**:
<img width="2992" height="1344" alt="Screenshot_1768764380"
src="https://github.com/user-attachments/assets/3c658f99-fa42-4dc8-9665-eda3f7776bf5"
/>
Custom **returnKeyType**s:
<img width="121" height="72" alt="Screenshot 2026-01-18 at 22 31 07"
src="https://github.com/user-attachments/assets/0f3027b2-e699-4880-81ba-16e1b6d2ed75"
/>
<img width="120" height="94" alt="Screenshot 2026-01-18 at 22 31 22"
src="https://github.com/user-attachments/assets/28582b76-9213-4937-a548-9971f5b26aac"
/>
<img width="123" height="81" alt="Screenshot 2026-01-18 at 22 31 37"
src="https://github.com/user-attachments/assets/ce8b5e9d-0591-4a3b-8afc-5ceb7b48a327"
/>
I advise you to test such props as **submitBehavior**,
**onSubmitEditing** yourself by pulling this branch and testing them
manually.
## Compatibility
| OS | Implemented |
| ------- | :---------: |
| iOS | ✅ |
| Android | ✅ |
### IMPORTANT NOTES
Some of the things were probably implemented poorly so I advice you to
not hesitate and jump in with proposals/your own changes in this PR
since I might not quickly return to this task.
1. I didn't use built-in type for **returnKeyType** in NativeProps
because codegen generates a mess when you pass a `type SomeType = "one"
| "two" | "three"` and I can't comprehend how to use. If you have a
better idea how to deal with it - please inform me about that;
2. Android multiline problem one - **returnKeyType** basically doesn't
work;
3. Android multiline problem two - for some reason listener of "Done"
button on keyboard doesn't work on multiline inputs, so I had to write a
somewhat hack in TextWatcher to handle the press of "Done" button;
4. Problem 3 is also present on iOS. Because of multiline input I have
to check for "\n" input to understand that we pressed "Done". So, if
user tries to copy-paste "\n" - then it might blur the input if we set
**submitBehavior** to blurAndSubmit (which is an unlikely scenario but
this a somewhat hack).
---------
Co-authored-by: Kacper Żółkiewski <kacper.zolkiewski@swmansion.com>
Co-authored-by: Igor Furgała <74370735+exploIF@users.noreply.github.com>
Co-authored-by: Kacper Żółkiewski <74975508+kacperzolkiewski@users.noreply.github.com>
Co-authored-by: Piotr Karamon <33125365+pkaramon@users.noreply.github.com>
Co-authored-by: Piotr Karamon <piotrkaramon3@gmail.com>
@@ -182,6 +201,53 @@ class EnrichedTextInputView : AppCompatEditText {
182
201
183
202
// Handle checkbox list item clicks
184
203
this.setCheckboxClickListener()
204
+
205
+
setOnEditorActionListener(this)
206
+
setReturnKeyLabel(DEFAULT_IME_ACTION_LABEL)
207
+
}
208
+
209
+
// Similar implementation to: https://github.com/facebook/react-native/blob/c1f5445f4a59d0035389725e47da58eb3d2c267c/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.kt#L940
210
+
overridefunonEditorAction(
211
+
v:TextView?,
212
+
actionId:Int,
213
+
event:KeyEvent?,
214
+
): Boolean {
215
+
// Check if it's a valid keyboard action (Done, Next, etc.) or the Enter key (IME_NULL)
216
+
val isAction = (actionId andEditorInfo.IME_MASK_ACTION) !=0|| actionId ==EditorInfo.IME_NULL
217
+
218
+
if (isAction) {
219
+
val shouldSubmit = shouldSubmitOnReturn()
220
+
val shouldBlur = shouldBlurOnReturn()
221
+
222
+
if (shouldSubmit) {
223
+
emitSubmitEditing()
224
+
}
225
+
226
+
if (shouldBlur) {
227
+
clearFocus()
228
+
}
229
+
230
+
if (shouldSubmit || shouldBlur) {
231
+
returntrue
232
+
}
233
+
}
234
+
235
+
// Return false to let the system handle default behavior (like inserting \n)
236
+
returnfalse
237
+
}
238
+
239
+
privatefunemitSubmitEditing() {
240
+
val context = context asReactContext
241
+
val surfaceId =UIManagerHelper.getSurfaceId(context)
242
+
val dispatcher =UIManagerHelper.getEventDispatcherForReactTag(context, id)
0 commit comments