diff --git a/web/src/components/RelativeModal.jsx b/web/src/components/RelativeModal.jsx
index d6b031226..705db416b 100644
--- a/web/src/components/RelativeModal.jsx
+++ b/web/src/components/RelativeModal.jsx
@@ -1,6 +1,5 @@
import { h, Fragment } from 'preact';
import { createPortal } from 'preact/compat';
-import { DarkModeProvider } from '../context';
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'preact/hooks';
const WINDOW_PADDING = 20;
@@ -76,7 +75,7 @@ export default function RelativeModal({ className, role = 'dialog', children, on
}, [show, position.width, ref.current]);
const menu = (
-
+
{children}
-
+
);
return portalRoot ? createPortal(menu, portalRoot) : menu;
diff --git a/web/src/context/index.jsx b/web/src/context/index.jsx
index 40ff9f560..09ceba80d 100644
--- a/web/src/context/index.jsx
+++ b/web/src/context/index.jsx
@@ -1,7 +1,7 @@
import { h, createContext } from 'preact';
import { get as getData, set as setData } from 'idb-keyval';
import produce from 'immer';
-import { useCallback, useContext, useEffect, useState } from 'preact/hooks';
+import { useCallback, useContext, useEffect, useLayoutEffect, useState } from 'preact/hooks';
const DarkMode = createContext(null);
@@ -54,11 +54,15 @@ export function DarkModeProvider({ children }) {
handleMediaMatch(query);
}, [persistedMode]);
- return (
-
- {children}
-
- );
+ useLayoutEffect(() => {
+ if (currentMode === 'dark') {
+ document.body.classList.add('dark');
+ } else {
+ document.body.classList.remove('dark');
+ }
+ }, [currentMode]);
+
+ return {children};
}
export function useDarkMode() {