-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix onSubmitEditing firing on delete/tab #442
Conversation
`-[RCTBaseTextInputView textInputShouldReturn]` also sends a submit event.
@@ -353,7 +353,7 @@ - (BOOL)textView:(NSTextView *)textView doCommandBySelector:(SEL)commandSelector | |||
BOOL commandHandled = NO; | |||
id<RCTBackedTextInputDelegate> textInputDelegate = [_backedTextInputView textInputDelegate]; | |||
// enter/return | |||
if (textInputDelegate.textInputShouldReturn && (commandSelector == @selector(insertNewline:) || commandSelector == @selector(insertNewlineIgnoringFieldEditor:))) { | |||
if ((commandSelector == @selector(insertNewline:) || commandSelector == @selector(insertNewlineIgnoringFieldEditor:)) && textInputDelegate.textInputShouldReturn) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tom-un, @shergin, @TheSavior: I don't have the full context on why textInputShouldReturn
also sends a submit event. Is this something we should fix upstream to avoid future surprises?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, the current behaviour is to always submit when pressing Enter. Is that the correct behaviour? How would one normally input a newline in a multiline TextInput? I had assumed that one would press Enter for newline, and submit with Cmd+Enter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed it to submit only on ⌘+Enter.
Summary
onSubmitEditing
is fired on delete/tab keys because we check-[RCTBaseTextInputView textInputShouldReturn]
, which also sends a submit event, too early.Resolves #429
Changelog
[macOS] [Fixed] - Fix onSubmitEditing firing on delete/tab
Test Plan
Microsoft Reviewers: Open in CodeFlow