Skip to content

Commit

Permalink
Fix order of mousedown, focus and mouseup
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lydell committed Aug 18, 2024
1 parent b5cb77a commit 0c567ea
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/worker/Program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 0c567ea

Please sign in to comment.