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

check for the closest anchor when trying to open a link #3923

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Changes from all commits
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
14 changes: 10 additions & 4 deletions apps/dashboard/app/javascript/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,17 @@ export function bindFullPageSpinnerEvent() {
// open links in javascript and display an alert
export function openLinkInJs(event) {
event.preventDefault();
const href = event.target.href;
let href = event.target.href;

// do nothing if there's no href.
if(href == null){
return;
// event.target could be a child of the anchor, so try that.
if(href == null) {
const closestAnchor = event.target.closest('a');
if(closestAnchor.hasChildNodes(event.target)) {
href = closestAnchor.href;
} else {
// event.target is not a child of an anhcor, so there's nothing to do.
return;
}
}

if(window.open(href) == null) {
Expand Down
Loading