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): [collapse] allow nested inputs in ElCollapseItem to … #14061

Merged
merged 6 commits into from
Aug 28, 2023

Conversation

kinggq
Copy link
Contributor

@kinggq kinggq commented Aug 23, 2023

…handle space key

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

This PR addresses an issue in the ElCollapseItem component where nested input elements within the component were unable to recognize and handle space key inputs due to a parent div capturing and preventing the event. The event handling logic has been updated to ensure that nested inputs can function as expected while still maintaining the desired behavior on the parent div. #14027

Related Issue

Fixes #14027

Explanation of Changes

  • Updated event handling logic on the parent div of ElCollapseItem by using .stop.prevent.self modifiers for the keypress.space.enter event. This ensures the event is only prevented when the event target is the div itself and not any child elements.

  • This change allows nested inputs to properly handle space key inputs while still maintaining the desired expand/collapse behavior on the parent div.

@pull-request-triage
Copy link

👋 @kinggq, 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 23, 2023
@github-actions
Copy link

github-actions bot commented Aug 23, 2023

@github-actions
Copy link

Hello @kinggq, 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 23, 2023

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

@btea
Copy link
Collaborator

btea commented Aug 23, 2023

The issue doesn't seem to be resolved. example

@kaine0923
Copy link
Contributor

the prevent directive stops the space default behavior, you could try to remove it

@btea
Copy link
Collaborator

btea commented Aug 24, 2023

space are equivalent to enter to toggle whether collapsed items are expanded, and prevent spaces from causing page scrolling by default, so they cannot be removed.

I don't think this issue needs to be solved, it's not a correct usage.

Co-authored-by: btea <2356281422@qq.com>
@kinggq
Copy link
Contributor Author

kinggq commented Aug 24, 2023

It seems that the modifications you made can indeed solve this problem

Copy link
Collaborator

@btea btea left a comment

Choose a reason for hiding this comment

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

Thanks!

@tolking tolking merged commit 69750fb into element-plus:dev Aug 28, 2023
10 checks passed
@element-bot element-bot mentioned this pull request Sep 14, 2023
3 tasks
consultation-applio pushed a commit to consultation-applio/element-plus that referenced this pull request Nov 10, 2023
…ement-plus#14061)

* fix(components): [collapse] allow nested inputs in ElCollapseItem to handle space key

* Update packages/components/collapse/src/collapse-item.vue

Co-authored-by: btea <2356281422@qq.com>

---------

Co-authored-by: btea <2356281422@qq.com>
@123xhao
Copy link

123xhao commented Apr 24, 2024

直接在input上面添加@keydown.space.stop @keyup.space.prevent这个阻止默认事件即可.

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.

[Component] [collapse-item] el-collapse-item自定义标题添加el-input,输入框无法输入空格
5 participants