fix(ui): harden theme toggle accessibility

This commit is contained in:
vince 2026-06-20 00:58:30 +02:00
parent cdb269e505
commit b923ac8947
8 changed files with 75 additions and 9 deletions

View file

@ -93,7 +93,7 @@ export default function App() {
const [theme, setTheme] = useState<UiTheme>(() => {
if (typeof window === "undefined") return "dark";
return resolveInitialUiTheme(window.localStorage);
return resolveInitialUiTheme(getThemeStorage());
});
useEffect(() => {
@ -113,7 +113,7 @@ export default function App() {
useEffect(() => {
document.documentElement.dataset.uiTheme = theme;
persistUiTheme(theme, window.localStorage);
persistUiTheme(theme, getThemeStorage());
}, [theme]);
useEffect(() => {
@ -173,3 +173,11 @@ function stateIcon(state: DashboardRuntimeState["state"]): string {
if (state === "loading") return "mdi:progress-clock";
return "mdi:tray";
}
function getThemeStorage(): Storage | undefined {
try {
return window.localStorage;
} catch {
return undefined;
}
}