mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
fix(CrudThemeProvider): Optimized theme loading logic (#35155)
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user