FIX: text selection breaks opening of links in new tabs (#19867)

When a user checks "Open all external links in a new tab" preference
he expects not to be overruled by unrelated text selections.
Yet if text is selected during a link click the link is followed on
the same tab. This change corrects that.
This commit is contained in:
Aleksey Bogdanov 2023-01-24 15:17:03 +02:00 committed by GitHub
parent eee97ad29a
commit 1bc39c1a4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,7 +5,6 @@ import User from "discourse/models/user";
import { ajax } from "discourse/lib/ajax";
import getURL, { samePrefix } from "discourse-common/lib/get-url";
import { isTesting } from "discourse-common/config/environment";
import { selectedText } from "discourse/lib/utilities";
import { wantsNewWindow } from "discourse/lib/intercept-click";
import deprecated from "discourse-common/lib/deprecated";
import { getOwner } from "discourse-common/lib/get-owner";
@ -80,14 +79,6 @@ export default {
return true;
}
// Cancel click if triggered as part of selection.
const selection = window.getSelection();
if (selection.type === "Range" || selection.rangeCount > 0) {
if (selectedText() !== "") {
return true;
}
}
const link = e.currentTarget;
const tracking = isValidLink(link);