-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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(input): clearOnEdit clears input when user initially types #26005
Conversation
@@ -432,37 +434,17 @@ export class Input implements ComponentInterface { | |||
this.isComposing = false; | |||
}; | |||
|
|||
private clearTextInput = (ev?: Event) => { | |||
private onClearButtonClick = (ev?: Event) => { |
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.
Renamed this function as it is the click handler for the button and should not be re-used directly by other parts of the implementation.
Instead if inner behavior needs to be shared, there should be another private function that both implementations call.
* Otherwise the value will not be cleared | ||
* if user is inside the input | ||
*/ | ||
if (this.nativeInput) { |
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.
This change was made 3 years ago. I am unable to replicate the original bug: #17055 with this removed.
* Clear the input if the control has not been previously cleared during focus. | ||
* Do not clear if the user hitting enter to submit a form. | ||
*/ | ||
if (!this.didInputClearOnEdit && this.hasValue() && ev.key !== '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.
This causes the value to be cleared when pressing keys like Ctrl and Shift that don't actually "type" anything. Not sure whether that's desired behavior.
Ok, this PR is updated to align with the conversations we had on the textarea |
Pull request checklist
Please check if your PR fulfills the following requirements:
ionic-docs
repo, in a separate PR. See the contributing guide for details.npm run build
) was run locally and any changes were pushednpm run lint
) has passed locally and any fixes were made for failuresPull request type
Please check the type of change your PR introduces:
What is the current behavior?
The
ion-input
field does not initially clear whenclearOnEdit
is enabled, with a default value, when the control is first focused and modified.ionInput
can emit an detail ofundefined
.Issue URL: Internal
What is the new behavior?
ion-input
withclearOnEdit
enabled will clear the input when the control receives focus and is modifiedionInput
correctly emits the parent event as the detail.Does this introduce a breaking change?
Other information