From fbcad55c0e1beba87ed4735b9bfc182b1f283a20 Mon Sep 17 00:00:00 2001 From: Josh Howenstine Date: Fri, 27 Sep 2024 07:24:00 -0700 Subject: [PATCH] fix: make sure subThemes are taken into account when generating style cache (#534) * fix: make sure subThemes are taken into account when generating style cache * fix: make sure style chain gets updated on subThemes * fix: cleanup comments and test file * fix: cleanup comments and test file * fix: revert theme manager changes --- packages/@lightningjs/ui-components/package.json | 2 +- .../src/mixins/withThemeStyles/StyleManager.js | 9 ++++++++- .../ui-components/src/mixins/withThemeStyles/index.js | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/@lightningjs/ui-components/package.json b/packages/@lightningjs/ui-components/package.json index b6f03bb44..fc0b2f9be 100644 --- a/packages/@lightningjs/ui-components/package.json +++ b/packages/@lightningjs/ui-components/package.json @@ -58,4 +58,4 @@ "publishConfig": { "access": "public" } -} +} \ No newline at end of file diff --git a/packages/@lightningjs/ui-components/src/mixins/withThemeStyles/StyleManager.js b/packages/@lightningjs/ui-components/src/mixins/withThemeStyles/StyleManager.js index 11251a837..55f7155e3 100644 --- a/packages/@lightningjs/ui-components/src/mixins/withThemeStyles/StyleManager.js +++ b/packages/@lightningjs/ui-components/src/mixins/withThemeStyles/StyleManager.js @@ -100,6 +100,13 @@ export default class StyleManager extends lng.EventEmitter { this.update(); } + /** + * Clears the style chain cache. + */ + clearStyleChainCache() { + clearStyleChainCache(); + } + /** * Clears the source cache. */ @@ -127,6 +134,7 @@ export default class StyleManager extends lng.EventEmitter { _generateCacheKey(name) { const cacheKey = [ name, + this.component._targetSubTheme, this.component.constructor.__componentName, this._customStyleHash ] @@ -204,7 +212,6 @@ export default class StyleManager extends lng.EventEmitter { // Style source does not exist so it will need to be generated. We attempt to run this function only when necessary for optimal performance styleSource = generateComponentStyleSource({ alias: this.component.constructor.aliasStyles, - componentConfig: this.component._componentConfig, inlineStyle: this.component._componentLevelStyle, styleChain: getStyleChainMemoized(this.component), theme: this.component.theme diff --git a/packages/@lightningjs/ui-components/src/mixins/withThemeStyles/index.js b/packages/@lightningjs/ui-components/src/mixins/withThemeStyles/index.js index 6fd500d82..97a8b769e 100644 --- a/packages/@lightningjs/ui-components/src/mixins/withThemeStyles/index.js +++ b/packages/@lightningjs/ui-components/src/mixins/withThemeStyles/index.js @@ -120,6 +120,7 @@ export default function withThemeStyles(Base, mixinStyle = {}) { if (this._targetSubTheme) { this._styleManager.clearListeners(); this._styleManager.setupListeners(); + this._styleManager.clearStyleChainCache(); this._styleManager.clearStyleCache(); this._styleManager.clearSourceCache(); this._styleManager.update();