Skip to content

Commit

Permalink
Fix Firefox detection for mouse button correction (internal-2195)
Browse files Browse the repository at this point in the history
  • Loading branch information
underoot committed Feb 13, 2025
1 parent f75aa8d commit afed1f2
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/util/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,9 @@ export function touchPos(el: HTMLElement, touches: TouchList): Array<Point> {

export function mouseButton(e: MouseEvent): number {
assert(e.type === 'mousedown' || e.type === 'mouseup');
// @ts-expect-error - TS2339 - Property 'InstallTrigger' does not exist on type 'Window & typeof globalThis'.
if (typeof window.InstallTrigger !== 'undefined' && e.button === 2 && e.ctrlKey &&
window.navigator.platform.toUpperCase().indexOf('MAC') >= 0) {
if (/firefox/i.test(navigator.userAgent) && /macintosh/i.test(navigator.userAgent) && e.button === 2 && e.ctrlKey) {
// Fix for https://github.com/mapbox/mapbox-gl-js/issues/3131:
// Firefox (detected by InstallTrigger) on Mac determines e.button = 2 when
// Firefox on Mac (detected by user agent) determines e.button = 2 when
// using Control + left click
return 0;
}
Expand Down

0 comments on commit afed1f2

Please sign in to comment.