Skip to content

Commit cc6dd90

Browse files
committed
Revert "feat: add support for opening list item link in new tab on middle mouse click"
This reverts commit cd844e9.
1 parent 370b536 commit cc6dd90

File tree

1 file changed

+33
-35
lines changed

1 file changed

+33
-35
lines changed

adminforth/spa/src/components/ResourceListTable.vue

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
</td>
8585
</tr>
8686

87-
<tr @mousedown="onClick($event,row)"
87+
<tr @click="onClick($event,row)"
8888
v-else v-for="(row, rowI) in rows" :key="`row_${row._primaryKeyValue}`"
8989
ref="rowRefs"
9090
class="bg-lightListTable dark:bg-darkListTable border-lightListBorder dark:border-gray-700 hover:bg-lightListTableRowHover dark:hover:bg-darkListTableRowHover"
@@ -457,50 +457,48 @@ function onSortButtonClick(event, field) {
457457
458458
const clickTarget = ref(null);
459459
460-
async function onClick(e, row) {
461-
if (clickTarget.value === e.target) return;
460+
async function onClick(e,row) {
461+
if(clickTarget.value === e.target) return;
462462
clickTarget.value = e.target;
463463
await new Promise((resolve) => setTimeout(resolve, 100));
464464
if (window.getSelection().toString()) return;
465-
if (e.button === 2) {
466-
return; // right click, do nothing
467-
}
468-
const openInNewTab =
469-
e.ctrlKey ||
470-
e.metaKey ||
471-
e.button === 1 ||
472-
(row._clickUrl?.includes('target=_blank'));
473-
474-
if (openInNewTab) {
475-
if (row._clickUrl) {
476-
window.open(row._clickUrl, '_blank');
465+
else {
466+
if (row._clickUrl === null) {
467+
// user asked to nothing on click
468+
return;
469+
}
470+
if (e.ctrlKey || e.metaKey || row._clickUrl?.includes('target=_blank')) {
471+
472+
if (row._clickUrl) {
473+
window.open(row._clickUrl, '_blank');
474+
} else {
475+
window.open(
476+
router.resolve({
477+
name: 'resource-show',
478+
params: {
479+
resourceId: props.resource.resourceId,
480+
primaryKey: row._primaryKeyValue,
481+
},
482+
}).href,
483+
'_blank'
484+
);
485+
}
477486
} else {
478-
window.open(
479-
router.resolve({
487+
if (row._clickUrl) {
488+
if (row._clickUrl.startsWith('http')) {
489+
document.location.href = row._clickUrl;
490+
} else {
491+
router.push(row._clickUrl);
492+
}
493+
} else {
494+
router.push({
480495
name: 'resource-show',
481496
params: {
482497
resourceId: props.resource.resourceId,
483498
primaryKey: row._primaryKeyValue,
484499
},
485-
}).href,
486-
'_blank'
487-
);
488-
}
489-
} else {
490-
if (row._clickUrl) {
491-
if (row._clickUrl.startsWith('http')) {
492-
document.location.href = row._clickUrl;
493-
} else {
494-
router.push(row._clickUrl);
500+
});
495501
}
496-
} else {
497-
router.push({
498-
name: 'resource-show',
499-
params: {
500-
resourceId: props.resource.resourceId,
501-
primaryKey: row._primaryKeyValue,
502-
},
503-
});
504502
}
505503
}
506504
}

0 commit comments

Comments
 (0)