-
Notifications
You must be signed in to change notification settings - Fork 13.5k
bug: clicking within ion-input on the label triggers (click) twice #30165
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
Comments
I think the framework may be behaving as expected. Here's an example using vanilla JS that shows the click event being dispatched twice when you listen for the event on a container element such as the following: <body>
<div id="container">
<label for="name">Name</label>
<input type="text" id="name" />
</div>
<script>
document
.getElementById('container')
.addEventListener('click', () => console.log('clicked'));
</script>
</body> |
Hello! While we're reviewing the fix for this, there's a dev build up that I believe addresses your issues: Edit: Since this was merged into main, this should be released in 8.5.8 this week. |
…n several components (#30384) Issue number: resolves #30165 --------- <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the current behavior? <!-- Please describe the current behavior that you are modifying. --> Currently, several components will trigger their `onClick` twice if you click on their labels. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> After this fix, the affected components will only trigger `onClick` once per click of their labels or click directly on the element. ## Does this introduce a breaking change? - [ ] Yes - [X] No <!-- If this introduces a breaking change: 1. Describe the impact and migration path for existing applications below. 2. Update the BREAKING.md file with the breaking change. 3. Add "BREAKING CHANGE: [...]" to the commit description when merging. See https://github.com/ionic-team/ionic-framework/blob/main/docs/CONTRIBUTING.md#footer for more information. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. --> The affected components are: - Checkbox - Select - Textarea - Toggle - Input I also tested radio and range but could not reproduce the issue for them. Note that two of the components, checkbox and toggle, had to have special implementations for both their test and fix because of how the host component acts as the component for accessibility purposes. Current dev build: `8.5.7-dev.11746044124.147aab6c` --------- Co-authored-by: Maria Hutt <[email protected]> Co-authored-by: Brandy Smith <[email protected]>
…n several components (#30384) Issue number: resolves #30165 --------- <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the current behavior? <!-- Please describe the current behavior that you are modifying. --> Currently, several components will trigger their `onClick` twice if you click on their labels. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> After this fix, the affected components will only trigger `onClick` once per click of their labels or click directly on the element. ## Does this introduce a breaking change? - [ ] Yes - [X] No <!-- If this introduces a breaking change: 1. Describe the impact and migration path for existing applications below. 2. Update the BREAKING.md file with the breaking change. 3. Add "BREAKING CHANGE: [...]" to the commit description when merging. See https://github.com/ionic-team/ionic-framework/blob/main/docs/CONTRIBUTING.md#footer for more information. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. --> The affected components are: - Checkbox - Select - Textarea - Toggle - Input I also tested radio and range but could not reproduce the issue for them. Note that two of the components, checkbox and toggle, had to have special implementations for both their test and fix because of how the host component acts as the component for accessibility purposes. Current dev build: `8.5.7-dev.11746044124.147aab6c` --------- Co-authored-by: Maria Hutt <[email protected]> Co-authored-by: Brandy Smith <[email protected]>
Prerequisites
Ionic Framework Version
v8.x
Current Behavior
When you click on an ion-input with attribute (click)="function", this function is called twice when you click on the label within that ion-input. When you click on the value it is called once (as it should).
Expected Behavior
That the function would only be called once when you click on the label within the ion-input
Steps to Reproduce
Stackblitz
Code Reproduction URL
https://stackblitz.com/edit/ubs56gug?file=src%2Fapp%2Fexample.component.html
Ionic Info
Its ionic from the current stackblitz config used in the docs, from package.json:
Additional Information
Adding event.preventDefault(); can be used as a dirty fix untill this issue gets resolved.
The text was updated successfully, but these errors were encountered: