Skip to content

Commit

Permalink
Merge pull request #28582 from filipemelo2002/fix/api-collapse-all
Browse files Browse the repository at this point in the history
UI: Fix collapse/expand all functionality
  • Loading branch information
ghengeveld committed Aug 1, 2024
2 parents 0b6b357 + d4b319d commit 735b97f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
11 changes: 8 additions & 3 deletions code/core/src/manager-api/modules/shortcuts.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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': {
Expand Down
3 changes: 2 additions & 1 deletion code/core/src/manager/container/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -222,7 +223,7 @@ export const useMenu = (
() => ({
id: 'collapse',
title: 'Collapse all',
onClick: () => api.collapseAll(),
onClick: () => api.emit(STORIES_COLLAPSE_ALL),
right: enableShortcuts ? <Shortcut keys={shortcutKeys.collapseAll} /> : null,
}),
[api, enableShortcuts, shortcutKeys]
Expand Down

0 comments on commit 735b97f

Please sign in to comment.