From 83ccc2eced4245cbf779a7e85cb73fe8bf6518b3 Mon Sep 17 00:00:00 2001 From: David Holdeman Date: Fri, 23 Jul 2021 16:05:43 -0500 Subject: [PATCH] fix bug of putting info in wrong table, and scrolling to top (#3042) --- misc/pinout-gen/script.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/misc/pinout-gen/script.js b/misc/pinout-gen/script.js index b75b6747c6..a67cd25856 100644 --- a/misc/pinout-gen/script.js +++ b/misc/pinout-gen/script.js @@ -37,8 +37,14 @@ function addRow(table, pin, cid) { clone.querySelector(".pin-data").dataset.type = pin.type; if (pin.pdiv) { row.addEventListener('click', function(table, pin, cid) { - clickPin(table.parentElement.parentElement.parentElement.querySelector(".info-table tbody"), pin, cid); - table.parentElement.parentElement.parentElement.scrollIntoView() + var container; + for (var elem = table; elem && elem !== document; elem = elem.parentNode) { + if (elem.matches(".container")) { + var container = elem; + }; + } + clickPin(container.querySelector(".info-table tbody"), pin, cid); + container.scrollIntoView() }.bind(null, table, pin, cid)); } table.appendChild(clone);