fix(CrudThemeProvider): Optimized theme loading logic (#35155)

This commit is contained in:
marun
2025-09-18 11:49:26 +08:00
committed by GitHub
parent 1f530d45cb
commit 1bf112a57a

View File

@@ -19,6 +19,7 @@
import { ReactNode, useEffect, useState } from 'react';
import { useThemeContext } from 'src/theme/ThemeProvider';
import { Theme } from '@superset-ui/core';
import { Loading } from '@superset-ui/core/components';
interface CrudThemeProviderProps {
children: ReactNode;
@@ -62,11 +63,16 @@ export default function CrudThemeProvider({
}
}, [themeId, globalThemeContext]);
// If no dashboard theme, just render children (they use global theme)
if (!themeId || !dashboardTheme) {
// If no themeId, just render children (they use global theme)
if (!themeId) {
return <>{children}</>;
}
// If themeId exists, but theme is not loaded yet, return null to prevent re-mounting children
if (!dashboardTheme) {
return <Loading />;
}
// Render children with the dashboard theme provider from controller
return (
<dashboardTheme.SupersetThemeProvider>