-
Notifications
You must be signed in to change notification settings - Fork 272
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(ui5-input): call change before submit event #10613
base: main
Are you sure you want to change the base?
Conversation
typo in branch name but should be fine :D |
Wrong BehaviorThe current implementation will only fire the submit event on enter if the input has changed. Prevent SubmittingBy facilitating
So with the planned modification the order of things would be correct.
UI5 WC should stay in line with this native behavior. So I would suggest to trigger the submit event as first thing within the |
this._enterKeyDown = true; | ||
|
||
if (isValueChanged && this._internals.form) { | ||
submitForm(this); |
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.
Why? This prevents firing of the change event. Defeats the purpose of the issu.
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.
Change should be fired if the value is changed since last (final) user interaction. As final user interaction (change event) is considered pressing Enter or focus out + value is changes since last focusin. Submit event should fire always when an Enter key is pressed (as in the native input)
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.
Ahhh, ok got it now.
The variable name is simply wrong. Should be "isValueUnchanged" or something...
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.
Then again, looking at the implementation of _handleEnter
: You also have logic for selecting suggestion items via "Enter".
Wouldn't that also (falsely) trigger the submit?
@@ -821,7 +827,7 @@ class Input extends UI5Element implements SuggestionComponent, IFormInputElement | |||
this.value = (e.target as HTMLInputElement).value; | |||
} | |||
|
|||
this._keyDown = false; | |||
this._enterKeyDown = false; |
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.
Wouldn't this prevent execution of the code in "_handleChange"? Keyup comes before focusout, which is used for the change event, right?
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.
Change event, by definition, is fired on key down of Enter key or on focusout
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.
Ok, didn't get the magic that _handleChange
is called implicitly when the change event is fired. So when change
is fired via the change event by pressing Enter
everything is fine!
EDIT: Thought that setting this here would have a side effect on _hanldeChange when triggered via _focusout. However, it's all fine here, because that shouldn't trigger a submit...
FIXES: #10534