File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import EventProvider from "./EventProvider.js";
33import insertFontFace from "./FontFace.js" ;
44import insertSystemCSSVars from "./SystemCSSVars.js" ;
55import insertScrollbarStyles from "./ScrollbarStyles.js" ;
6- import { getTheme } from "./config/Theme.js" ;
6+ import { getTheme , getBaseTheme } from "./config/Theme.js" ;
77import applyTheme from "./theming/applyTheme.js" ;
88import { registerCurrentRuntime } from "./Runtimes.js" ;
99import { getFeature } from "./FeaturesRegistry.js" ;
@@ -88,8 +88,15 @@ const boot = async (): Promise<void> => {
8888 * @param { string } theme
8989 */
9090const onThemeRegistered = ( theme : string ) => {
91- if ( booted && theme === getTheme ( ) ) { // getTheme should only be called if "booted" is true
92- applyTheme ( getTheme ( ) ) ;
91+ if ( ! booted ) {
92+ return ;
93+ }
94+
95+ const currentTheme = getTheme ( ) ;
96+ const currentBaseTheme = getBaseTheme ( ) ;
97+
98+ if ( theme === currentTheme || theme === currentBaseTheme ) {
99+ applyTheme ( currentTheme ) ;
93100 }
94101} ;
95102
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import { boot, isBooted } from "../Boot.js";
77import { attachConfigurationReset } from "./ConfigurationReset.js" ;
88
99let curTheme : string | undefined ;
10+ let curBaseTheme : string | undefined = undefined ;
1011
1112attachConfigurationReset ( ( ) => {
1213 curTheme = undefined ;
@@ -91,11 +92,31 @@ const isLegacyThemeFamilyAsync = async () => {
9192
9293const isKnownTheme = ( theme : string ) => SUPPORTED_THEMES . includes ( theme ) ;
9394
95+ /**
96+ * Returns the base theme of external theme.
97+ * @private
98+ * @returns {string | undefined } the base theme name
99+ */
100+ const getBaseTheme = ( ) : string | undefined => {
101+ return curBaseTheme ;
102+ } ;
103+
104+ /**
105+ * Sets the base theme of the current external theme.
106+ * @param { string | undefined } theme the name of the new base theme
107+ * @private
108+ */
109+ const setBaseTheme = ( theme : string | undefined ) : void => {
110+ curBaseTheme = theme ;
111+ } ;
112+
94113export {
95114 getTheme ,
96115 setTheme ,
97116 isTheme ,
98117 isLegacyThemeFamily ,
99118 isLegacyThemeFamilyAsync ,
100119 getDefaultTheme ,
120+ getBaseTheme ,
121+ setBaseTheme ,
101122} ;
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import getThemeDesignerTheme from "./getThemeDesignerTheme.js";
44import { fireThemeLoaded } from "./ThemeLoaded.js" ;
55import { getFeature } from "../FeaturesRegistry.js" ;
66import { attachCustomThemeStylesToHead , getThemeRoot } from "../config/ThemeRoot.js" ;
7+ import { setBaseTheme } from "../config/Theme.js" ;
78import type OpenUI5Support from "../features/OpenUI5Support.js" ;
89import { DEFAULT_THEME } from "../generated/AssetParameters.js" ;
910import { getCurrentRuntimeIndex } from "../Runtimes.js" ;
@@ -87,9 +88,13 @@ const applyTheme = async (theme: string) => {
8788 }
8889
8990 // Always load component packages properties. For non-registered themes, try with the base theme, if any
90- const packagesTheme = isThemeRegistered ( theme ) ? theme : extTheme && extTheme . baseThemeName ;
91- await loadComponentPackages ( packagesTheme || DEFAULT_THEME , extTheme && extTheme . themeName === theme ? theme : undefined ) ;
91+ const externalThemeName = extTheme && extTheme . themeName === theme ? theme : undefined ;
92+ const baseThemeName = extTheme && extTheme . baseThemeName ;
93+ const effectiveThemeName = isThemeRegistered ( theme ) ? theme : ( baseThemeName || DEFAULT_THEME ) ;
9294
95+ await loadComponentPackages ( effectiveThemeName , externalThemeName ) ;
96+
97+ setBaseTheme ( baseThemeName ) ;
9398 fireThemeLoaded ( theme ) ;
9499} ;
95100
You can’t perform that action at this time.
0 commit comments