From d795d4e46da2925b1c554be73eaeb58915076176 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20D=C3=A9ramond?= Date: Sat, 23 Dec 2023 16:58:35 +0100 Subject: [PATCH] Fix edge case in `color-modes.js` (#408) --- src/assets/js/color-modes.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/assets/js/color-modes.js b/src/assets/js/color-modes.js index 2f7fab98f..36a420b0c 100644 --- a/src/assets/js/color-modes.js +++ b/src/assets/js/color-modes.js @@ -18,8 +18,8 @@ } const setTheme = theme => { - if (theme === 'auto' && window.matchMedia('(prefers-color-scheme: dark)').matches) { - document.documentElement.setAttribute('data-bs-theme', 'dark') + if (theme === 'auto') { + document.documentElement.setAttribute('data-bs-theme', (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) } else { document.documentElement.setAttribute('data-bs-theme', theme) }