Skip to content

Conversation

@IslamRustamov
Copy link
Contributor

@IslamRustamov IslamRustamov commented Jan 18, 2026

Summary

Fixes: #295

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:

Screenshot_1768764380

Custom returnKeyTypes:

Screenshot 2026-01-18 at 22 31 07 Screenshot 2026-01-18 at 22 31 22 Screenshot 2026-01-18 at 22 31 37

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).

@IslamRustamov IslamRustamov changed the title Feature/add submit related props feat: add returnKeyType, submitBehavior, onSubmitEditing, returnKeyLabel props Jan 18, 2026
@kacperzolkiewski
Copy link
Collaborator

kacperzolkiewski commented Jan 19, 2026

Unfortunately on Android this PR makes that when we press enter in input nothing happens:

Screen.Recording.2026-01-19.at.12.50.06.mov

Even when I pass prop: submitBehavior="newline"

@kacperzolkiewski
Copy link
Collaborator

kacperzolkiewski commented Jan 19, 2026

About second point:
Android multiline problem one - returnKeyType basically doesn't work;

I tested it on TextInput from react-native and it looks like it does not work also in their implementation.

Screen.Recording.2026-01-19.at.13.03.54.mov

So we can drop support for this prop on Android

@kacperzolkiewski
Copy link
Collaborator

kacperzolkiewski commented Jan 19, 2026

If I add at the same time returnKeyType and returnKeyLabel e.g.

returnKeyType="next"
returnKeyLabel="Next"

and press on label there is a crash on Android:

Screen.Recording.2026-01-19.at.13.26.03.mov

When we will drop support for returnKeyType for Android there should not be this crash

@IslamRustamov IslamRustamov force-pushed the feature/add-submit-related-props branch from e900c88 to 91e68e4 Compare January 20, 2026 20:01
@IslamRustamov
Copy link
Contributor Author

IslamRustamov commented Jan 20, 2026

@kacperzolkiewski I've made requested changes

+ regarding the crash on Android when we press on action label. This crash is happening right now on main branch too. It is happening because for some reason this text input thinks that there is some other text input that it should focus on after the action label is pressed and since there is no other text inputs - it crashes with "focus search returned a view that wasn't able to take focus!". I've added commit that sets up ime action label in prepareComponent to unspecified action so that the crash would be avoided, but ideally there should be an ability to focus on next text input on ime action label press if there are any. (probably should be done separately, not in this PR)

+ not sure if it's a big deal or not but on Android when we pass "blurAndSubmit" for example and we hit Enter - we also receive a text changed event, not just submit editing event. Since I can't think of anything else but a hacky way to handle this (creating a boolean variable ignoreAfterTextChanged that sets to true in onTextChanged and then sets to false in afterTextChanged) I'm not sure what would be the best approach here.

@IslamRustamov IslamRustamov force-pushed the feature/add-submit-related-props branch from 6125334 to f4feec2 Compare January 20, 2026 20:44
@kacperzolkiewski
Copy link
Collaborator

kacperzolkiewski commented Jan 21, 2026

@IslamRustamov,
Thank you for your work 🙏
I pushed update for the Android implementation, with the fix for receiving also a text changed event while we passed "blurAndSubmit" and also removed hacky way of checking if there is \n sign inserted in input.
I override onEditorAction function and I manage (shouldSubmit, shouldBlur) there, so we do not need to check newline manually and also it does not fire onTextChange because it is not called - system recognizes that it is submit action no newline insertion.

What do you think about that?

@IslamRustamov
Copy link
Contributor Author

I think that's the most correct way to do that.

I initially tried to use the same thing but due to lack of proper knowledge of Android development I didn't set up onEditorAction correctly and it just didn't fire for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EnrichedTextInputProps support onSubmitEditing and returnKey and blurOnSubmit

3 participants