summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.changeset/short-flies-itch.md5
-rw-r--r--packages/astro/src/core/errors/overlay.ts3
2 files changed, 7 insertions, 1 deletions
diff --git a/.changeset/short-flies-itch.md b/.changeset/short-flies-itch.md
new file mode 100644
index 000000000..929bdec52
--- /dev/null
+++ b/.changeset/short-flies-itch.md
@@ -0,0 +1,5 @@
+---
+"astro": patch
+---
+
+Fixed errorOverlay theme toggle bug.
diff --git a/packages/astro/src/core/errors/overlay.ts b/packages/astro/src/core/errors/overlay.ts
index 282c79cd6..9bfc562ba 100644
--- a/packages/astro/src/core/errors/overlay.ts
+++ b/packages/astro/src/core/errors/overlay.ts
@@ -593,13 +593,14 @@ class ErrorOverlay extends HTMLElement {
window.matchMedia('(prefers-color-scheme: dark)').matches)
) {
this?.classList.add('astro-dark');
+ localStorage.astroErrorOverlayTheme = 'dark';
themeToggle!.checked = true;
} else {
this?.classList.remove('astro-dark');
themeToggle!.checked = false;
}
themeToggle?.addEventListener('click', () => {
- const isDark = localStorage.astroErrorOverlayTheme === 'dark';
+ const isDark = localStorage.astroErrorOverlayTheme === 'dark' || this?.classList.contains('astro-dark');
this?.classList.toggle('astro-dark', !isDark);
localStorage.astroErrorOverlayTheme = isDark ? 'light' : 'dark';
});