diff --git a/code/core/src/manager-api/modules/shortcuts.ts b/code/core/src/manager-api/modules/shortcuts.ts index 1d4708425c92..e65a7767faa9 100644 --- a/code/core/src/manager-api/modules/shortcuts.ts +++ b/code/core/src/manager-api/modules/shortcuts.ts @@ -1,6 +1,11 @@ /* eslint-disable @typescript-eslint/naming-convention */ import { global } from '@storybook/global'; -import { FORCE_REMOUNT, PREVIEW_KEYDOWN } from '@storybook/core/core-events'; +import { + FORCE_REMOUNT, + PREVIEW_KEYDOWN, + STORIES_COLLAPSE_ALL, + STORIES_EXPAND_ALL, +} from '@storybook/core/core-events'; import type { ModuleFn } from '../lib/types'; @@ -356,11 +361,11 @@ export const init: ModuleFn = ({ store, fullAPI, provider }) => { break; } case 'collapseAll': { - fullAPI.collapseAll(); + fullAPI.emit(STORIES_COLLAPSE_ALL); break; } case 'expandAll': { - fullAPI.expandAll(); + fullAPI.emit(STORIES_EXPAND_ALL); break; } case 'remount': { diff --git a/code/core/src/manager/container/Menu.tsx b/code/core/src/manager/container/Menu.tsx index 02c28ca994ac..ce1cce434226 100644 --- a/code/core/src/manager/container/Menu.tsx +++ b/code/core/src/manager/container/Menu.tsx @@ -6,6 +6,7 @@ import type { API, State } from '@storybook/core/manager-api'; import { shortcutToHumanString } from '@storybook/core/manager-api'; import { styled, useTheme } from '@storybook/core/theming'; import { CheckIcon, InfoIcon, ShareAltIcon, WandIcon } from '@storybook/icons'; +import { STORIES_COLLAPSE_ALL } from '@storybook/core/core-events'; const focusableUIElements = { storySearchField: 'storybook-explorer-searchfield', @@ -222,7 +223,7 @@ export const useMenu = ( () => ({ id: 'collapse', title: 'Collapse all', - onClick: () => api.collapseAll(), + onClick: () => api.emit(STORIES_COLLAPSE_ALL), right: enableShortcuts ? : null, }), [api, enableShortcuts, shortcutKeys]