diff --git a/superset-frontend/src/components/CrudThemeProvider.tsx b/superset-frontend/src/components/CrudThemeProvider.tsx
index aa6ddab3fa84..9e62902aa00e 100644
--- a/superset-frontend/src/components/CrudThemeProvider.tsx
+++ b/superset-frontend/src/components/CrudThemeProvider.tsx
@@ -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 ;
+ }
+
// Render children with the dashboard theme provider from controller
return (