Skip to content

A platform for community discussion. Free, open, simple.

UX: support middle click to open topic in new tab for Horizon (#38942)

Krisafd2707b7f7b
diff --git a/themes/horizon/javascripts/discourse/initializers/topic-list-columns.gjs b/themes/horizon/javascripts/discourse/initializers/topic-list-columns.gjs
index abb0f86b22d..812dcf50e4b 100644
--- a/themes/horizon/javascripts/discourse/initializers/topic-list-columns.gjs
+++ b/themes/horizon/javascripts/discourse/initializers/topic-list-columns.gjs
@@ -197,7 +197,12 @@ export default {
.closest("tr")
.querySelector("a.raw-topic-link");
- // Redispatch the click on the topic link, so that all key-handing is sorted
+ if (event.button === 1) {
+ // click events with button=1 can't naturally trigger browser navigation
+ window.open(topicLink.href, "_blank", "noopener,noreferrer");
+ return;
+ }
+
topicLink.dispatchEvent(
new MouseEvent("click", {
ctrlKey: event.ctrlKey,