feat(components): [el-menu] allow user to hide menu when clicking outside#14742
feat(components): [el-menu] allow user to hide menu when clicking outside#14742kooriookami merged 43 commits intoelement-plus:devfrom
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 |
ryuhangyeong
left a comment
There was a problem hiding this comment.
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 |
chenxch
left a comment
There was a problem hiding this comment.
@cuongle-hdwebsoft Sorry, I missed the message. Judging from the current results, I have no doubts. Thank you for everything.


when user sets
menu-triggertoclickand then clicking outside, it should be close menuclosed #14738
Please make sure these boxes are checked before submitting your PR, thank you!
devbranch.Description
🤖 Generated by Copilot at fb1c4cf
This pull request adds a
onClickOutsidefeature to thesub-menucomponent 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
onClickOutsidefunction from@vueuse/corelibrary to detect clicks outside of sub-menu elements (link)mouseInChildreactive property to sub-menu component to track whether the mouse is inside the sub-menu items or not (link, link)onClickOutsidefunction in sub-menu component'ssetupfunction, 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)