fix(gui): run a context menu item once on a double-click

The menu stays clickable during its 200ms fade-out, so the second click
of a double-click ran the item again: double-clicking Share… or
Properties in the dashboard opened two stacked dialogs. A menu that has
started closing now ignores item clicks.
This commit is contained in:
Nariman Jelveh committed 2026-10-23 15:11:27 -07:00
1 parent 9843e0ebc8
commit 56b80ff4cf
1 file changed
+6
+6
View File
@@ -605,6 +605,7 @@ function UIContextMenu (options) {
const fade_remove = (item) => {
const parent_data_id = $(item).closest('.context-menu').attr('data-parent-id');
const $stack = $(`#context-menu-${menu_id}, .context-menu[data-element-id="${parent_data_id}"]`);
$stack.addClass('context-menu-closing');
// Animate visible menus out. fadeOut's callback does not fire on
// already-hidden elements (e.g. a parent sheet hidden when its submenu
// opened), so force-remove the whole stack after the animation.
@@ -638,6 +639,11 @@ function UIContextMenu (options) {
// An item is clicked. Bound on the menu, not delegated from document, so
// the handler (and the items its closure holds) goes when the menu does.
$(contextMenu).on('click', 'li:not(.context-menu-item-disabled)', function (e) {
// A double-click's second click lands while the menu fades out; the
// item has run already (opening a dialog twice, say).
if ( $(contextMenu).hasClass('context-menu-closing') ) {
return false;
}
// onClick
if ( options.items[$(this).attr('data-action')].onClick && typeof options.items[$(this).attr('data-action')].onClick === 'function' ) {