From e268e1c6fee3f25c70c21368d9ae06d73bb4481e Mon Sep 17 00:00:00 2001 From: Jeff Ohrstrom Date: Thu, 31 Oct 2024 17:00:11 -0400 Subject: [PATCH] check for the closest anchor when trying to open a link --- apps/dashboard/app/javascript/utils.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/apps/dashboard/app/javascript/utils.js b/apps/dashboard/app/javascript/utils.js index dd46dcc0d1..913a850760 100644 --- a/apps/dashboard/app/javascript/utils.js +++ b/apps/dashboard/app/javascript/utils.js @@ -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) {