Fix menu popup dblclick on MacOS (#4989)

This commit is contained in:
windingwind 2025-01-17 19:00:01 +01:00 • committed by GitHub
parent e11d93f0bc
commit 998315dd58
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -138,6 +138,7 @@ Services.scriptloader.loadSubScript('chrome://zotero/content/elements/itemTreeMe
if (this !== e.target) {
return;
}
this.style.removeProperty("pointer-events");
// Following the implementation from https://searchfox.org/mozilla-esr102/source/toolkit/content/widgets/menupopup.js
let haveCheckableChild = this.querySelector(
":scope > menuitem:not([hidden]):is([type=checkbox],[type=radio],[selected],[checked])"
@ -187,12 +188,31 @@ Services.scriptloader.loadSubScript('chrome://zotero/content/elements/itemTreeMe
// This event is triggered after clicking the menu and before popuphiding
// where we control whether the fade out animation should run
this.addEventListener("command", () => {
if (this.getAttribute("animate") === "false") {
const commandCallback = (e) => {
let animateState = this.getAttribute("animate");
if (animateState === "false") {
return;
}
// Do not trigger the event if the popup is already closing
if (animateState === "false-once") {
e.preventDefault();
e.stopPropagation();
return;
}
// Disable the fading animation when the popup is closed by clicking
this.setAttribute("animate", "false-once");
this.style.pointerEvents = "none";
};
this.addEventListener("command", commandCallback, {
capture: true,
mozSystemGroup: true,
});
// Sometimes the `command` event is not triggered, also listen to `click` event
// For example, when the menuitem has `command` attribute
this.addEventListener("click", commandCallback, {
capture: true,
mozSystemGroup: true,
});
// The _moz-menuactive attribute isn't removed from menulist items