Skip to content

Commit

Permalink
Fix memoization issue of Panel
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinpalkovic committed Jan 13, 2025
1 parent b451851 commit 523f051
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions code/core/src/manager/container/Panel.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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;
Expand All @@ -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),
Expand Down

0 comments on commit 523f051

Please sign in to comment.