Refactor ThemeContext to ensure fallback to light scheme and update color scheme logic

This commit is contained in:
2025-06-04 19:17:09 +02:00
parent 54feefcd5c
commit 07af3f6e39
3 changed files with 10 additions and 24 deletions

View File

@@ -22,8 +22,10 @@ export const ThemeProvider: React.FC<ThemeProviderProps> = ({ children }) => {
const updateColorScheme = useCallback(
(newTheme: MantineColorScheme): void => {
if (setColorScheme) {
setColorScheme(newTheme);
if (newTheme === 'light' || newTheme === 'dark') {
if (setColorScheme) {
setColorScheme(newTheme);
}
}
},
[setColorScheme]
@@ -31,7 +33,8 @@ export const ThemeProvider: React.FC<ThemeProviderProps> = ({ children }) => {
// Ensure colorScheme is never undefined by falling back to light theme
const value: ThemeContextType = {
colorScheme: colorScheme || 'light',
colorScheme:
colorScheme === 'light' || colorScheme === 'dark' ? colorScheme : 'light',
updateColorScheme,
};