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;
-
+