From 70297b67878177adc627cf88f3f7ee3ccc8ef74a Mon Sep 17 00:00:00 2001 From: Yann Braga Date: Thu, 15 Feb 2024 11:58:28 +0100 Subject: [PATCH 1/4] Merge pull request #26042 from storybookjs/yann/fix-addon-themes-types Addon Themes: Make type generic less strict (cherry picked from commit 999fc2aeeabacc06c419aff695060d44fb49922a) --- code/addons/themes/src/decorators/class-name.decorator.tsx | 3 ++- code/addons/themes/src/decorators/data-attribute.decorator.tsx | 3 ++- code/addons/themes/src/decorators/provider.decorator.tsx | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/code/addons/themes/src/decorators/class-name.decorator.tsx b/code/addons/themes/src/decorators/class-name.decorator.tsx index ccbe4fbf7f31..0306c5ea9912 100644 --- a/code/addons/themes/src/decorators/class-name.decorator.tsx +++ b/code/addons/themes/src/decorators/class-name.decorator.tsx @@ -13,7 +13,8 @@ const DEFAULT_ELEMENT_SELECTOR = 'html'; const classStringToArray = (classString: string) => classString.split(' ').filter(Boolean); -export const withThemeByClassName = ({ +// TODO check with @kasperpeulen: change the types so they can be correctly inferred from context e.g. any> +export const withThemeByClassName = ({ themes, defaultTheme, parentSelector = DEFAULT_ELEMENT_SELECTOR, diff --git a/code/addons/themes/src/decorators/data-attribute.decorator.tsx b/code/addons/themes/src/decorators/data-attribute.decorator.tsx index 546885db8d62..4009fd9073a0 100644 --- a/code/addons/themes/src/decorators/data-attribute.decorator.tsx +++ b/code/addons/themes/src/decorators/data-attribute.decorator.tsx @@ -12,7 +12,8 @@ export interface DataAttributeStrategyConfiguration { const DEFAULT_ELEMENT_SELECTOR = 'html'; const DEFAULT_DATA_ATTRIBUTE = 'data-theme'; -export const withThemeByDataAttribute = ({ +// TODO check with @kasperpeulen: change the types so they can be correctly inferred from context e.g. any> +export const withThemeByDataAttribute = ({ themes, defaultTheme, parentSelector = DEFAULT_ELEMENT_SELECTOR, diff --git a/code/addons/themes/src/decorators/provider.decorator.tsx b/code/addons/themes/src/decorators/provider.decorator.tsx index 6063034eb859..0466a29e6ac8 100644 --- a/code/addons/themes/src/decorators/provider.decorator.tsx +++ b/code/addons/themes/src/decorators/provider.decorator.tsx @@ -16,7 +16,8 @@ export interface ProviderStrategyConfiguration { const pluckThemeFromKeyPairTuple = ([_, themeConfig]: [string, Theme]): Theme => themeConfig; -export const withThemeFromJSXProvider = ({ +// TODO check with @kasperpeulen: change the types so they can be correctly inferred from context e.g. any> +export const withThemeFromJSXProvider = ({ Provider, GlobalStyles, defaultTheme, From 7a985800d1aad8a8c3e712b2b3e1908b7e4dce12 Mon Sep 17 00:00:00 2001 From: storybook-bot <32066757+storybook-bot@users.noreply.github.com> Date: Thu, 15 Feb 2024 11:00:54 +0000 Subject: [PATCH 2/4] Write changelog for 7.6.16 [skip ci] --- CHANGELOG.md | 4 ++++ code/package.json | 3 ++- docs/versions/latest.json | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c0d554b6714..70f0e79dcbdc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 7.6.16 + +- Addon Themes: Make type generic less strict - [#26042](https://github.com/storybookjs/storybook/pull/26042), thanks [@yannbf](https://github.com/yannbf)! + ## 7.6.15 - Interaction: Make sure that adding spies doesn't cause infinite loops with self referencing args [#26019](https://github.com/storybookjs/storybook/pull/26019), thanks @kasperpeulen! diff --git a/code/package.json b/code/package.json index 6586bbc4e238..dc1c72395b08 100644 --- a/code/package.json +++ b/code/package.json @@ -329,5 +329,6 @@ "Dependency Upgrades" ] ] - } + }, + "deferredNextVersion": "7.6.16" } diff --git a/docs/versions/latest.json b/docs/versions/latest.json index 87082c218fc5..88d3166541df 100644 --- a/docs/versions/latest.json +++ b/docs/versions/latest.json @@ -1 +1 @@ -{"version":"7.6.15","info":{"plain":"- Interaction: Make sure that adding spies doesn't cause infinite loops with self referencing args [#26019](https://github.com/storybookjs/storybook/pull/26019), thanks @kasperpeulen!"}} +{"version":"7.6.16","info":{"plain":"- Addon Themes: Make type generic less strict - [#26042](https://github.com/storybookjs/storybook/pull/26042), thanks [@yannbf](https://github.com/yannbf)!"}} From 91a89211c3b6560aad9501567891ae3ec5df4c56 Mon Sep 17 00:00:00 2001 From: Kasper Peulen Date: Tue, 13 Feb 2024 15:37:54 +0100 Subject: [PATCH 3/4] Revert 24451 (cherry picked from commit 9a7a820c2ab52ed95c5f79add46320bee97b6d3a) --- code/addons/interactions/src/preview.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/code/addons/interactions/src/preview.ts b/code/addons/interactions/src/preview.ts index 54c7c18faab5..357471394bef 100644 --- a/code/addons/interactions/src/preview.ts +++ b/code/addons/interactions/src/preview.ts @@ -1,6 +1,5 @@ -/* eslint-disable no-param-reassign,no-underscore-dangle */ +/* eslint-disable no-param-reassign, no-underscore-dangle */ /// - import { addons } from '@storybook/preview-api'; import { global } from '@storybook/global'; import { FORCE_REMOUNT, STORY_RENDER_PHASE_CHANGED } from '@storybook/core-events'; @@ -21,6 +20,7 @@ const fn = JestMock.fn.bind(JestMock); // Aliasing `fn` to `action` here, so we get a more descriptive label in the UI. const { action } = instrument({ action: fn }, { retain: true }); const channel = addons.getChannel(); +const seen = new Set(); const spies: any[] = []; channel.on(FORCE_REMOUNT, () => spies.forEach((mock) => mock?.mockClear?.())); @@ -29,6 +29,8 @@ channel.on(STORY_RENDER_PHASE_CHANGED, ({ newPhase }) => { }); const addSpies = (id: string, val: any, key?: string): any => { + if (seen.has(val)) return val; + seen.add(val); try { if (Object.prototype.toString.call(val) === '[object Object]') { // We have to mutate the original object for this to survive HMR. From 6e6b5b7d4b1c9094f0e07a14c50eaee7460340ce Mon Sep 17 00:00:00 2001 From: Kasper Peulen Date: Thu, 15 Feb 2024 12:53:14 +0100 Subject: [PATCH 4/4] Fix CHANGELOG.md --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70f0e79dcbdc..39e2411abc61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,11 @@ ## 7.6.16 - Addon Themes: Make type generic less strict - [#26042](https://github.com/storybookjs/storybook/pull/26042), thanks [@yannbf](https://github.com/yannbf)! +- Interaction: Make sure that adding spies doesn't cause infinite loops with self referencing args [#26019](https://github.com/storybookjs/storybook/pull/26019), thanks @kasperpeulen! ## 7.6.15 -- Interaction: Make sure that adding spies doesn't cause infinite loops with self referencing args [#26019](https://github.com/storybookjs/storybook/pull/26019), thanks @kasperpeulen! +This release accidentally didn't contain anything. ## 7.6.14