diff --git a/client/components/dropdown/dropdown.jsx b/client/components/dropdown/dropdown.jsx index 9ace9cca3..892b5b199 100644 --- a/client/components/dropdown/dropdown.jsx +++ b/client/components/dropdown/dropdown.jsx @@ -72,6 +72,24 @@ const Dropdown = ({ groupName, className = null, icon, children, color = null, c } }; + // handle clicks on menu items. By default, actions do dismiss. + const handleMenuActionClick = (event)=>{ + const menuElement = menuRef.current; + if(!menuElement) return; + + const menuAction = event.target.closest('button, a, [role="menuitem"]'); + if(!menuAction || !menuElement.contains(menuAction)) return; + + // don't dismiss if the target triggers a submenu + if(menuAction.hasAttribute('popoverTarget')) return; + + // don't dismiss if the target has `no-dismiss` attribute + const noDismissValue = menuAction.getAttribute('no-dismiss')?.toLowerCase(); + if(noDismissValue === '' || noDismissValue === 'true') return; + + document.querySelectorAll('.menu-list:popover-open').forEach((openMenu)=>openMenu.hidePopover()); + }; + return (
diff --git a/client/homebrew/editor/snippetbar/snippetbar.jsx b/client/homebrew/editor/snippetbar/snippetbar.jsx index f240bc9b7..f60980bf5 100644 --- a/client/homebrew/editor/snippetbar/snippetbar.jsx +++ b/client/homebrew/editor/snippetbar/snippetbar.jsx @@ -322,7 +322,6 @@ const SnippetGroup = createReactClass({ }; }, handleSnippetClick : function(e, snippet){ - e.stopPropagation(); this.props.onSnippetClick(execute(snippet.gen, this.props)); }, renderSnippets : function(snippets){