From 6dd3a20abada71ff0095219a536f38752b64dce5 Mon Sep 17 00:00:00 2001 From: kernc Date: Fri, 18 Feb 2022 16:16:33 +0100 Subject: [PATCH] Upon style change, re-scroll to :target --- switcher.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/switcher.js b/switcher.js index 7d03fbf..30f1f5b 100644 --- a/switcher.js +++ b/switcher.js @@ -33,6 +33,7 @@ function inline_switcher() { select_close = ' \n ' dropdown = dropdown + select_close; switcher.innerHTML = dropdown; + dropdown = switcher.getElementById('switcher_dropdown'); } function add_switcher() { @@ -43,6 +44,8 @@ function add_switcher() { css_link.rel="stylesheet"; css_link.type="text/css"; css_link.href="https://dohliam.github.io/dropin-minimal-css/min/" + frameworks.split(",")[0] + ".min.css"; + // Scroll to where we were and preserve combobox focus + css_link.onload= () => { window.location.hash = window.location.hash; dropdown.focus(); } head.appendChild(css_link); }