From 1e3090b0331ccf28fc9da3ef265cd77c3e2dda61 Mon Sep 17 00:00:00 2001 From: Niklas Mohrin Date: Mon, 12 Feb 2024 22:11:22 +0100 Subject: [PATCH] Use click handlers instead of inserting anchor tags in `.table-seamless-links` This way we don't need to think about the DOM elements being moved around and we can stop click events in nested elements. --- evap/evaluation/templates/base.html | 9 +++------ evap/static/scss/components/_tables.scss | 11 ----------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/evap/evaluation/templates/base.html b/evap/evaluation/templates/base.html index 80cf0e3889..e43781306c 100644 --- a/evap/evaluation/templates/base.html +++ b/evap/evaluation/templates/base.html @@ -179,12 +179,9 @@ // activate clickable hover tables document.querySelectorAll(".table-seamless-links [data-url]").forEach(row => { - for(const table_data of row.children) { - const wrapping_anchor = document.createElement("a"); - wrapping_anchor.href = row.dataset["url"]; - wrapping_anchor.append(...table_data.childNodes); - table_data.replaceChildren(wrapping_anchor); - } + row.addEventListener("click", () => { + window.location.assign(row.dataset.url); + }); }); document.querySelectorAll(".hover-row").forEach(row => { diff --git a/evap/static/scss/components/_tables.scss b/evap/static/scss/components/_tables.scss index 13e0b174e0..1256914ca1 100644 --- a/evap/static/scss/components/_tables.scss +++ b/evap/static/scss/components/_tables.scss @@ -35,19 +35,8 @@ $table-colors: ( padding-bottom: 0.4rem; } -// Seamless links in tables -// -// -1- Expand links to fill the cell .table-seamless-links td { overflow: hidden; - - a:not(.btn) { - color: $black; - text-decoration: none; - display: block; // -1- - margin: -10em; // -1- - padding: 10em; // -1- - } } // Hoverable rows