From 0c567ea7410bfb557a18e7621caa18d7d7831e48 Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Sun, 18 Aug 2024 15:22:26 +0200 Subject: [PATCH] Fix order of mousedown, focus and mouseup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We used a wrong order of mousedown, focus and mouseup (compared to what can be observed when making a real click) on purpose as a workaround for Gmail. This caused some dropdowns not to work on Codeberg. By switching to the correct event order, Codeberg works. I’ve tested Gmail, and didn’t notice any problems anymore. Closes #76. --- src/worker/Program.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/worker/Program.ts b/src/worker/Program.ts index 58b1db0..7427c72 100644 --- a/src/worker/Program.ts +++ b/src/worker/Program.ts @@ -947,14 +947,12 @@ export default class WorkerProgram { } // When clicking a link for real the focus happens between the mousedown and - // the mouseup, but moving this line between those two `.dispatchEvent` calls - // below causes dropdowns in gmail not to be triggered anymore. + // the mouseup. // Note: The target element is clicked, but the original element is // focused. The idea is that the original element is a link or button, and // the target element might be a span or div. - element.focus(); - targetElement.dispatchEvent(mousedownEvent); + element.focus(); targetElement.dispatchEvent(mouseupEvent); let defaultPrevented = !targetElement.dispatchEvent(clickEvent);