浏览代码

fix: open ctrl/cmd + click in new tab

Alexander Musikhin 2 周之前
父节点
当前提交
6ef6de1ae9
共有 1 个文件被更改,包括 11 次插入6 次删除
  1. 11 6
      resources/views/partials/table.blade.php

+ 11 - 6
resources/views/partials/table.blade.php

@@ -88,7 +88,6 @@
             <tr
                 @if($rowAnchor) id="{{ $rowAnchor }}" data-row-id="{{ $rowId }}" @endif
                 @if($rowHref) data-row-href="{{ $rowHref }}" @endif
-                @if($id === 'reclamations') data-open-target="_blank" @endif
             >
                 @foreach($header as $headerName => $headerTitle)
                     <td class="column_{{$headerName}}"
@@ -415,14 +414,13 @@
             return $(target).closest('a, button, input, select, textarea, label, .dropdown, [data-bs-toggle], [data-no-row-select]').length > 0;
         }
 
-        function openRow($row) {
+        function openRow($row, newTab = false) {
             const href = $row.data('row-href');
             if (!href) {
                 return;
             }
             selectRow($row, false);
-            const target = $row.data('open-target');
-            if (target === '_blank') {
+            if (newTab) {
                 window.open(href, '_blank');
             } else {
                 window.location.href = href;
@@ -453,10 +451,17 @@
                 return;
             }
             const $row = $(this);
+
+            // На десктопах с Ctrl открываем в новой вкладке сразу по одиночному клику
+            const isTouchDevice = window.matchMedia('(pointer: coarse)').matches || ('ontouchstart' in window);
+            if (!isTouchDevice && (e.ctrlKey || e.metaKey)) {
+                openRow($row, true);
+                return;
+            }
+
             selectRow($row);
 
             // На мобильных dblclick часто не срабатывает, поэтому поддерживаем двойной тап.
-            const isTouchDevice = window.matchMedia('(pointer: coarse)').matches || ('ontouchstart' in window);
             if (!isTouchDevice) {
                 return;
             }
@@ -480,7 +485,7 @@
             if (isRowActionTarget(e.target)) {
                 return;
             }
-            openRow($(this));
+            openRow($(this), e.ctrlKey || e.metaKey);
         });
 
         $('.toggle-column').on('change', function () {