From a115309f4f2e3389d8d86aff8e827b59ebc090fa Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Fri, 22 Oct 2021 02:19:32 +0800 Subject: [PATCH] Fix the click behavior for and with [data-href] (#17388) --- web_src/js/features/common-global.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/web_src/js/features/common-global.js b/web_src/js/features/common-global.js index bf4e97769d..b345afd4cf 100644 --- a/web_src/js/features/common-global.js +++ b/web_src/js/features/common-global.js @@ -119,14 +119,19 @@ export function initGlobalCommon() { $($(this).data('target')).slideToggle(100); }); - // make table element clickable like a link - $('tr[data-href]').on('click', function () { - window.location = $(this).data('href'); - }); - - // make table element clickable like a link - $('td[data-href]').click(function () { - window.location = $(this).data('href'); + // make table and elements clickable like a link + $('tr[data-href], td[data-href]').on('click', function (e) { + const href = $(this).data('href'); + if (e.target.nodeName === 'A') { + // if a user clicks on , then the or should not act as a link. + return; + } + if (e.ctrlKey || e.metaKey) { + // ctrl+click or meta+click opens a new window in modern browsers + window.open(href); + } else { + window.location = href; + } }); }