From: Julien Déramond Date: Sun, 8 Jan 2023 14:58:59 +0000 (+0100) Subject: Remove autofocus on theme switch when page is loaded X-Git-Tag: v5.3.0-alpha2~161 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=39905711fab711ac6f99f8a987931bdee9376b66;p=thirdparty%2Fbootstrap.git Remove autofocus on theme switch when page is loaded --- diff --git a/site/static/docs/5.3/assets/js/color-modes.js b/site/static/docs/5.3/assets/js/color-modes.js index fdd3303dc6..68717f82d6 100644 --- a/site/static/docs/5.3/assets/js/color-modes.js +++ b/site/static/docs/5.3/assets/js/color-modes.js @@ -27,7 +27,7 @@ setTheme(getPreferredTheme()) - const showActiveTheme = theme => { + const showActiveTheme = (theme, focus = false) => { const themeSwitcher = document.querySelector('#bd-theme') const themeSwitcherText = document.querySelector('#bd-theme-text') const activeThemeIcon = document.querySelector('.theme-icon-active use') @@ -44,7 +44,10 @@ activeThemeIcon.setAttribute('href', svgOfActiveBtn) const themeSwitcherLabel = `${themeSwitcherText.textContent} (${btnToActive.dataset.bsThemeValue})` themeSwitcher.setAttribute('aria-label', themeSwitcherLabel) - themeSwitcher.focus() + + if (focus) { + themeSwitcher.focus() + } } window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => { @@ -62,7 +65,7 @@ const theme = toggle.getAttribute('data-bs-theme-value') localStorage.setItem('theme', theme) setTheme(theme) - showActiveTheme(theme) + showActiveTheme(theme, true) }) }) })