aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Déramond <[email protected]>2023-01-08 15:58:59 +0100
committerMark Otto <[email protected]>2023-01-08 15:39:31 -0800
commit39905711fab711ac6f99f8a987931bdee9376b66 (patch)
tree707faad690409fe4373f31c77ac75f2517133df5
parent1e33cfa272542a9facf03033d765a5a3d86d3a35 (diff)
downloadbootstrap-39905711fab711ac6f99f8a987931bdee9376b66.tar.xz
bootstrap-39905711fab711ac6f99f8a987931bdee9376b66.zip
Remove autofocus on theme switch when page is loaded
-rw-r--r--site/static/docs/5.3/assets/js/color-modes.js9
1 files changed, 6 insertions, 3 deletions
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 fdd3303dc..68717f82d 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)
})
})
})