-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
feat(components): [el-menu] allow user to hide menu when clicking outside #14742
Conversation
when user sets `menu-trigger` to `click` and then clicking outside, it should be close menu closed element-plus#14738
👋 @cuongle-hdwebsoft, thank you for contributing element-plus. |
Hello @cuongle-hdwebsoft, thank you for contributing to element-plus, please see our guideline to see how to make contribution |
🧪 Playground Preview: https://element-plus.run/?pr=14742 |
I was just wondering if we can provide a prop for the menu, such as "collapse-on-click-outside," to allow the user to decide whether to hide it when clicking outside. |
Thank you for your suggestion @Dmaziyo. I think that's a good spot and I will add new props |
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.
great!
I think it's a good feature.
However, this is more of a feature than a bug fix. |
Please change tag version to |
Yes I've done @kooriookami |
I have a question, when I clicked the submenu, the menu hide QQ2023127-94835-HD.mp4May be can refer to What do you think? @btea @ryuhangyeong @chenxch |
There are already attributes related to |
When clicking outside, that |
I hope I can receive new feedback. Did I address your question correctly? Otherwise Could you please make it clear to me? @chenxch |
@cuongle-hdwebsoft I suggest that hide-timeout only works in |
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.
Thank your contribute! It's a great feature.
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.
@cuongle-hdwebsoft Sorry, I missed the message. Judging from the current results, I have no doubts. Thank you for everything.
when user sets
menu-trigger
toclick
and then clicking outside, it should be close menuclosed #14738
Please make sure these boxes are checked before submitting your PR, thank you!
dev
branch.Description
🤖 Generated by Copilot at fb1c4cf
This pull request adds a
onClickOutside
feature to thesub-menu
component and disables auto-formatting in VSCode. It improves the user experience of the menu and avoids potential code style issues.Related Issue
Fixes #14738
Explanation of Changes
🤖 Generated by Copilot at fb1c4cf
onClickOutside
function from@vueuse/core
library to detect clicks outside of sub-menu elements (link)mouseInChild
reactive property to sub-menu component to track whether the mouse is inside the sub-menu items or not (link, link)onClickOutside
function in sub-menu component'ssetup
function, passing the popper element and a callback that closes the sub-menu if the mouse is outside of the sub-menu trigger and items (link)