From faa54c823825156d6f591f5347f8fb98d072a5d2 Mon Sep 17 00:00:00 2001 From: Mike Rockwell Date: Thu, 24 Jul 2025 12:25:15 -0400 Subject: [PATCH] Add id=top to body and add auto scroll when details block is closed --- app.js | 6 +++++- index.html | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index b27fde8..4501bbc 100644 --- a/app.js +++ b/app.js @@ -1,10 +1,14 @@ // Set expanded value block to a variable const valueBlock = document.getElementById("value-expanded"); +const bodyTop = document.getElementById("top"); // Watch for the details element to be toggled document.querySelector('.value-block').addEventListener('toggle', function() { if (this.open) { // Scroll to contents of value block when it is opened valueBlock.scrollIntoView({ behavior: "smooth" }); - } + } else { + // Scroll to top of button list when value block is closed + bodyTop.scrollIntoView({ behavior: "smooth" }); + } }); diff --git a/index.html b/index.html index 3858a9c..2357317 100644 --- a/index.html +++ b/index.html @@ -27,7 +27,7 @@ - +