Pārlūkot izejas kodu

Don't focus new tab on middle click

This is more in line with how the browser behaves on middle click
Svilen Markov 7 mēneši atpakaļ
vecāks
revīzija
afe6ad6bfc

+ 1 - 1
internal/assets/static/js/main.js

@@ -262,7 +262,7 @@ function setupGroups() {
                         return;
                     }
 
-                    openURLInNewTab(title.dataset.titleUrl);
+                    openURLInNewTab(title.dataset.titleUrl, false);
                     event.preventDefault();
                 });
             }

+ 4 - 2
internal/assets/static/js/utils.js

@@ -28,6 +28,8 @@ export function clamp(value, min, max) {
     return Math.min(Math.max(value, min), max);
 }
 
-export function openURLInNewTab(url) {
-    window.open(url, '_blank', 'noopener,noreferrer')?.focus();
+export function openURLInNewTab(url, focus = true) {
+    const newWindow = window.open(url, '_blank', 'noopener,noreferrer');
+
+    if (focus && newWindow != null) newWindow.focus();
 }