Skip to content
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(components): [radio checkbox] fix click event triggered twice #13936

Merged
merged 2 commits into from
Aug 15, 2023

Conversation

FrontEndDog
Copy link
Member

@FrontEndDog FrontEndDog commented Aug 10, 2023

Please make sure these boxes are checked before submitting your PR, thank you!

  • Make sure you follow contributing guide English | (中文 | Español | Français).
  • Make sure you are merging your commits to dev branch.
  • Add some descriptions and refer to relative issues for your PR.

Description

if I using radio or checkbox in dropdown,@command will trigger twice

image

This problem is caused by input and label

look here

Related Issue

Fixes #___.

Explanation of Changes

🤖 Generated by Copilot at 4f66a48

  • Prevent click events from bubbling up and triggering change events twice in checkbox and radio components (link, link, link, link, link, link)
  • Add @click.stop modifier to el-button and el-checkbox components in checkbox-button.vue and checkbox.vue files (link, link, link, link)
  • Add @click.stop modifier to el-button and el-radio components in radio-button.vue and radio.vue files (link, link)

@pull-request-triage
Copy link

👋 @FrontEndDog, seems like this is your first time contribution to element-plus.

  • Please make sure that you have read our guidelines and code of conduct before making a contribution.
  • You can comment with /label Components:[component_name] to add a label for which component you are working on.
  • You may join our Discord for staying tuned.

@pull-request-triage pull-request-triage bot added 1st contribution Their very first contribution Needs Review labels Aug 10, 2023
@github-actions
Copy link

github-actions bot commented Aug 10, 2023

@github-actions
Copy link

Hello @FrontEndDog, thank you for contributing to element-plus, please see our guideline to see how to make contribution

@github-actions
Copy link

github-actions bot commented Aug 10, 2023

🧪 Playground Preview: https://element-plus.run/?pr=13936
Please comment the example via this playground if needed.

@btea btea changed the title fix(components): [radio checkbox] fix @click event triggered twice fix(components): [radio checkbox] fix click event triggered twice Aug 10, 2023
Copy link
Member

@ryuhangyeong ryuhangyeong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like a bug, but I wonder if there are many use cases for doing something with @click events on checkboxes and radio buttons. 🤔

@FrontEndDog
Copy link
Member Author

It looks like a bug, but I wonder if there are many use cases for doing something with @click events on checkboxes and radio buttons. 🤔

Whether used or not, triggering a click event twice is itself an error。

I came up with a scene,if click card edge,Triggered once,if click radio,Triggered twice

look here

Copy link
Member

@ryuhangyeong ryuhangyeong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tolking
Copy link
Member

tolking commented Aug 13, 2023

Thank for your contribution.

I do not think this is a BUG, You can use the change event instead of the click event.

If add the @click.stop to input, the click event will not be triggered when input is clicked, which is also unreasonable behavior.

@FrontEndDog
Copy link
Member Author

Thank for your contribution.

I do not think this is a BUG, You can use the change event instead of the click event.

If add the @click.stop to input, the click event will not be triggered when input is clicked, which is also unreasonable behavior.

The issue you mentioned will only appear in the native input and label,will not appear in element plus。

because input in element-plus is hidden。

@FrontEndDog
Copy link
Member Author

FrontEndDog commented Aug 14, 2023

To supplement, This issue was discovered when I was using el-dropdown, if I use @change instead of @command, the change event will not be triggered when click the el-dropdown-item edge. This is not what I want.

So I should use @command, but @command will triggered twice when without click.stop, This is clearly a bug.

image

demo is here

@tolking
Copy link
Member

tolking commented Aug 15, 2023

The issue you mentioned will only appear in the native input and label,will not appear in element plus。
because input in element-plus is hidden。

what you said makes sense.

Thank for your contribution

@tolking tolking merged commit 95e411e into element-plus:dev Aug 15, 2023
10 checks passed
@element-bot element-bot mentioned this pull request Aug 25, 2023
3 tasks
laizuan pushed a commit to laizuan/element-plus that referenced this pull request Sep 5, 2023
@FrontEndDog FrontEndDog deleted the fix-label-input branch September 25, 2023 10:23
consultation-applio pushed a commit to consultation-applio/element-plus that referenced this pull request Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants