From 1bc39c1a4fc4e1e0c7162fbd6aa347874a0685a9 Mon Sep 17 00:00:00 2001 From: Aleksey Bogdanov Date: Tue, 24 Jan 2023 15:17:03 +0200 Subject: [PATCH] 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. --- app/assets/javascripts/discourse/app/lib/click-track.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/app/assets/javascripts/discourse/app/lib/click-track.js b/app/assets/javascripts/discourse/app/lib/click-track.js index 05be231b7e5..04290714033 100644 --- a/app/assets/javascripts/discourse/app/lib/click-track.js +++ b/app/assets/javascripts/discourse/app/lib/click-track.js @@ -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);