Skip to content

Commit 1bf112a

Browse files
authored
fix(CrudThemeProvider): Optimized theme loading logic (#35155)
1 parent 1f530d4 commit 1bf112a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

superset-frontend/src/components/CrudThemeProvider.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import { ReactNode, useEffect, useState } from 'react';
2020
import { useThemeContext } from 'src/theme/ThemeProvider';
2121
import { Theme } from '@superset-ui/core';
22+
import { Loading } from '@superset-ui/core/components';
2223

2324
interface CrudThemeProviderProps {
2425
children: ReactNode;
@@ -62,11 +63,16 @@ export default function CrudThemeProvider({
6263
}
6364
}, [themeId, globalThemeContext]);
6465

65-
// If no dashboard theme, just render children (they use global theme)
66-
if (!themeId || !dashboardTheme) {
66+
// If no themeId, just render children (they use global theme)
67+
if (!themeId) {
6768
return <>{children}</>;
6869
}
6970

71+
// If themeId exists, but theme is not loaded yet, return null to prevent re-mounting children
72+
if (!dashboardTheme) {
73+
return <Loading />;
74+
}
75+
7076
// Render children with the dashboard theme provider from controller
7177
return (
7278
<dashboardTheme.SupersetThemeProvider>

0 commit comments

Comments
 (0)