From 7ddc9af49d06c42714df47411f75bbaabd384f61 Mon Sep 17 00:00:00 2001 From: Krystal Siler Date: Fri, 14 Aug 2020 10:39:51 -0700 Subject: [PATCH] Set "WhiteColors" as palette id for host palette if no id is provided (#395) * Change files * Remove change file * Set "WhiteColors" as palette id if no id is provided * Change files * Create helper function for palette cache key --- ...heming-react-native-2020-08-12-17-25-28-colorsFix.json | 8 ++++++++ .../src/NativeModule/ThemingModuleHelpers.ts | 8 ++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 change/@uifabricshared-theming-react-native-2020-08-12-17-25-28-colorsFix.json diff --git a/change/@uifabricshared-theming-react-native-2020-08-12-17-25-28-colorsFix.json b/change/@uifabricshared-theming-react-native-2020-08-12-17-25-28-colorsFix.json new file mode 100644 index 000000000..3f3669b0f --- /dev/null +++ b/change/@uifabricshared-theming-react-native-2020-08-12-17-25-28-colorsFix.json @@ -0,0 +1,8 @@ +{ + "type": "patch", + "comment": "Set \"WhiteColors\" as palette id if no id is provided", + "packageName": "@uifabricshared/theming-react-native", + "email": "krsiler@microsoft.com", + "dependentChangeType": "patch", + "date": "2020-08-13T00:25:28.785Z" +} diff --git a/packages/framework/theming-react-native/src/NativeModule/ThemingModuleHelpers.ts b/packages/framework/theming-react-native/src/NativeModule/ThemingModuleHelpers.ts index 37f8a6a57..569539075 100644 --- a/packages/framework/theming-react-native/src/NativeModule/ThemingModuleHelpers.ts +++ b/packages/framework/theming-react-native/src/NativeModule/ThemingModuleHelpers.ts @@ -32,8 +32,12 @@ function updatePaletteInCache(module: IOfficeThemingModule, cache: PaletteCache, } } +const getPaletteCacheKey = (palette?: string) => { + return useFakePalette ? 'debug' : palette || 'WhiteColors'; +}; + function translatePalette(module: IOfficeThemingModule, paletteCache: PaletteCache, palette?: string): IPartialPalette { - const key = useFakePalette ? 'debug' : palette || 'WhiteColors'; + const key = getPaletteCacheKey(palette); if (!paletteCache[key]) { updatePaletteInCache(module, paletteCache, key); } @@ -52,7 +56,7 @@ export function translateOfficeTheme(module: IOfficeThemingModule, cache: Palett }, typography: module.fluentTypography, host: { - palette: cache[id] + palette: cache[getPaletteCacheKey(id)] } }; }