From ab05ed9532ff30f8070981e081d3787c7db0fe96 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Thu, 13 Jun 2024 20:00:26 +0200 Subject: [PATCH] bootstrap5 dark mode toggle unset on dark browser preference, fixes #1340 --- CHANGELOG.md | 1 + js/dark-mode-switch.js | 5 +++-- tpl/bootstrap5.php | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0797555..34d9485a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * CHANGED: Enable strict type checking in PHP (#1350) * FIXED: Reset password input field on creation of new paste (#1194) * FIXED: Allow database schema upgrade to skip versions (#1343) +* FIXED: `bootstrap5` dark mode toggle unset on dark browser preference (#1340) ## 1.7.3 (2024-05-13) * CHANGED: Various tweaks of the `bootstrap5` template, suggested by the community diff --git a/js/dark-mode-switch.js b/js/dark-mode-switch.js index 9d7524bc..07288ee6 100644 --- a/js/dark-mode-switch.js +++ b/js/dark-mode-switch.js @@ -68,9 +68,10 @@ } else { delStoredPrettifyTheme() } - setTheme(getStoredPreferredTheme()) const toggle = document.querySelector('#bd-theme') - toggle.checked = getStoredTheme() === 'dark' + const theme = getStoredPreferredTheme() + setTheme(theme) + toggle.checked = (theme === 'dark') toggle.addEventListener('change', (event) => { const theme = event.currentTarget.checked ? 'dark' : 'light' setStoredTheme(theme) diff --git a/tpl/bootstrap5.php b/tpl/bootstrap5.php index 2edf7c29..9bf7feb0 100644 --- a/tpl/bootstrap5.php +++ b/tpl/bootstrap5.php @@ -42,7 +42,7 @@ endif; - +