From 523f051861bea75f89ed425728cefce01e5aeec0 Mon Sep 17 00:00:00 2001 From: Valentin Palkovic Date: Mon, 13 Jan 2025 09:41:02 +0100 Subject: [PATCH] Fix memoization issue of Panel --- code/core/src/manager/container/Panel.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/code/core/src/manager/container/Panel.tsx b/code/core/src/manager/container/Panel.tsx index 25292bd50769..1331e0f8cc67 100644 --- a/code/core/src/manager/container/Panel.tsx +++ b/code/core/src/manager/container/Panel.tsx @@ -1,7 +1,7 @@ import type { FC } from 'react'; import React from 'react'; -import { Addon_TypesEnum } from '@storybook/core/types'; +import { type API_LeafEntry, Addon_TypesEnum } from '@storybook/core/types'; import { Consumer } from '@storybook/core/manager-api'; import type { API, Combo } from '@storybook/core/manager-api'; @@ -16,9 +16,8 @@ const createPanelActions = memoize(1)((api) => ({ togglePosition: () => api.togglePanelPosition(), })); -const getPanels = memoize(1)((api: API) => { +const getPanels = memoize(1)((api: API, story: API_LeafEntry) => { const allPanels = api.getElements(Addon_TypesEnum.PANEL); - const story = api.getCurrentStoryData(); if (!allPanels || !story || story.type !== 'story') { return allPanels; @@ -45,7 +44,7 @@ const getPanels = memoize(1)((api: API) => { }); const mapper = ({ state, api }: Combo) => ({ - panels: getPanels(api), + panels: getPanels(api, api.getCurrentStoryData()), selectedPanel: api.getSelectedPanel(), panelPosition: state.layout.panelPosition, actions: createPanelActions(api),