mirror of
https://github.com/outline/outline.git
synced 2025-12-21 10:39:41 -06:00
fix: Middle click read-only doc link in FF opens duplicate tabs (#10122)
closes #10083
This commit is contained in:
@@ -5,6 +5,7 @@ import { isDocumentUrl, isInternalUrl } from "@shared/utils/urls";
|
||||
import { sharedModelPath } from "~/utils/routeHelpers";
|
||||
import { isHash } from "~/utils/urls";
|
||||
import useStores from "./useStores";
|
||||
import { isFirefox } from "@shared/utils/browser";
|
||||
|
||||
type Params = {
|
||||
/** The share ID of the document being viewed, if any */
|
||||
@@ -78,6 +79,12 @@ export default function useEditorClickHandlers({ shareId }: Params) {
|
||||
window.open(navigateTo, "_blank");
|
||||
}
|
||||
} else {
|
||||
// Middle-click events in Firefox are not prevented in the same way as other browsers
|
||||
// so we need to explicitly return here to prevent two tabs from being opened when
|
||||
// middle-clicking a link (#10083).
|
||||
if (event?.button === 1 && isFirefox()) {
|
||||
return;
|
||||
}
|
||||
window.open(href, "_blank");
|
||||
}
|
||||
},
|
||||
|
||||
@@ -230,7 +230,7 @@ export default class Link extends Mark {
|
||||
click: (_view: EditorView, event: MouseEvent) => {
|
||||
if (
|
||||
!(event.target instanceof HTMLAnchorElement) ||
|
||||
event.button !== 0
|
||||
(event.button !== 0 && event.button !== 1)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -91,6 +91,13 @@ export function isSafari(): boolean {
|
||||
);
|
||||
}
|
||||
|
||||
export function isFirefox(): boolean {
|
||||
if (!isBrowser) {
|
||||
return false;
|
||||
}
|
||||
return window.navigator.userAgent.includes("Firefox");
|
||||
}
|
||||
|
||||
let supportsPassive = false;
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user