-
Notifications
You must be signed in to change notification settings - Fork 723
fix: autoHide never applied to a nested trigger with a different trigger mode #808
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| --- | ||
| currentMenu: nested-triggers-autohide | ||
| --- | ||
|
|
||
| # Demo: Nested Triggers With Autohide | ||
|
|
||
| <!-- START doctoc generated TOC please keep comment here to allow auto update --> | ||
| <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> | ||
|
|
||
|
|
||
| - [Example code](#example-code) | ||
| - [Example HTML](#example-html) | ||
|
|
||
| <!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
|
|
||
| <span class="context-menu-two btn btn-neutral" style="display: block; width: 480px; height: 240px;"> | ||
| <span class="context-menu-one btn btn-neutral">left click me!</span> | ||
| <br> | ||
| right click anywhere in this box | ||
| </span> | ||
|
|
||
| <div style="height: 240px;"></div> | ||
|
|
||
| ## Example code | ||
|
|
||
| <script type="text/javascript" class="showcase"> | ||
| $(function(){ | ||
| var items = { | ||
| "edit": {name: "Edit", icon: "edit"}, | ||
| "cut": {name: "Cut", icon: "cut"}, | ||
| "copy": {name: "Copy", icon: "copy"}, | ||
| "paste": {name: "Paste", icon: "paste"}, | ||
| "delete": {name: "Delete", icon: "delete"}, | ||
| "sep1": "---------", | ||
| "quit": {name: "Quit", icon: function($element, key, item){ return 'context-menu-icon context-menu-icon-quit'; }} | ||
| }; | ||
|
|
||
| $.contextMenu({ | ||
| selector: '.context-menu-one', | ||
| className: 'menu-one', | ||
| trigger: 'left', | ||
| autoHide: true, | ||
| callback: function(key, options) { | ||
| var m = "clicked: " + key; | ||
| window.console && console.log(m) || alert(m); | ||
| }, | ||
| items: items | ||
| }); | ||
|
|
||
| $.contextMenu({ | ||
| selector: '.context-menu-two', | ||
| className: 'menu-two', | ||
| trigger: 'right', | ||
| autoHide: true, | ||
| callback: function(key, options) { | ||
| var m = "clicked: " + key; | ||
| window.console && console.log(m) || alert(m); | ||
| }, | ||
| items: items | ||
| }); | ||
| }); | ||
| </script> | ||
|
|
||
| ## Example HTML | ||
| <div style="display:none;" class="showcase" data-showcase-import=".context-menu-two"></div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
When a right-click menu is open and the user left-clicks a nested left-trigger,
showTargetcalls$.fn.contextMenu, whose coordinate overload triggers a bubbling syntheticcontextmenuevent. Any applicationcontextmenulistener on an ancestor of the nested trigger therefore fires for a plain left click before the plugin's delegated document handler can stop it. Dispatch the matched menu directly, ashandle.clickdoes, rather than reintroducing the synthetic event leakage that direct dispatch was designed to avoid.Useful? React with 👍 / 👎.