Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the click behavior for <tr> and <td> with [data-href] #17388

Merged
merged 2 commits into from
Oct 21, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions web_src/js/features/common-global.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,19 @@ export function initGlobalCommon() {
$($(this).data('target')).slideToggle(100);
});

// make table <tr> element clickable like a link
$('tr[data-href]').on('click', function () {
window.location = $(this).data('href');
});

// make table <td> element clickable like a link
$('td[data-href]').click(function () {
window.location = $(this).data('href');
// make table <tr> and <td> 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 <a>, then the <tr> or <td> 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;
}
});
}

Expand Down