From 45cfc11af6e9be45d3935d81c83f5d2182c0d8a1 Mon Sep 17 00:00:00 2001 From: jce <28319872+JasperCraeghs@users.noreply.github.com> Date: Wed, 3 Jan 2024 11:40:47 +0100 Subject: [PATCH] if an item was selected, ensure it's displayed at the top of the viewport --- mlx/traceability/assets/traceability.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mlx/traceability/assets/traceability.js b/mlx/traceability/assets/traceability.js index fea9e6f8..fd02bb46 100644 --- a/mlx/traceability/assets/traceability.js +++ b/mlx/traceability/assets/traceability.js @@ -58,6 +58,15 @@ $(document).ready(function () { $('p.admonition-title').each(function (i) { $(this).children('a').first().denyPermalinkStyling($(this)); }); + + // if an item was selected, ensure it's displayed at the top of the viewport + if (location.hash) { + const anchorId = location.hash.slice(1); + const element = document.getElementById(anchorId); + if (element) { + element.scrollIntoView(true, { block: "start", inline: "nearest" }); + } + } }); // item