Skip to content

Commit

Permalink
Merge pull request #25486 from storybookjs/yann/remove-expand-collaps…
Browse files Browse the repository at this point in the history
…e-methods

Core: Remove collapseAll and expandAll methods
  • Loading branch information
yannbf authored Jan 5, 2024
2 parents c624a02 + e82fe80 commit e8278ce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
13 changes: 13 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
- [storyIndexers](#storyindexers)
- [Deprecated docs parameters](#deprecated-docs-parameters)
- [Description Doc block properties](#description-doc-block-properties)
- [Manager API expandAll and collapseAll methods](#manager-api-expandall-and-collapseall-methods)
- [From version 7.5.0 to 7.6.0](#from-version-750-to-760)
- [CommonJS with Vite is deprecated](#commonjs-with-vite-is-deprecated)
- [Using implicit actions during rendering is deprecated](#using-implicit-actions-during-rendering-is-deprecated)
Expand Down Expand Up @@ -676,6 +677,18 @@ More info [here](#autodocs-changes) and [here](#source-block).

`children`, `markdown` and `type` are now removed in favor of the `of` property. [More info](#doc-blocks).

#### Manager API expandAll and collapseAll methods

The `collapseAll` and `expandAll` APIs (possibly used by addons) are now removed. Please emit events for these actions instead:

```ts
import { STORIES_COLLAPSE_ALL, STORIES_EXPAND_ALL } from '@storybook/core-events';
import { useStorybookApi } from '@storybook/manager-api';

const api = useStorybookApi()
api.collapseAll() // becomes api.emit(STORIES_COLLAPSE_ALL)
api.expandAll() // becomes api.emit(STORIES_EXPAND_ALL)
```

## From version 7.5.0 to 7.6.0

Expand Down
17 changes: 0 additions & 17 deletions code/lib/manager-api/src/modules/channel.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable no-param-reassign */
import { STORIES_COLLAPSE_ALL, STORIES_EXPAND_ALL } from '@storybook/core-events';
import type { Listener } from '@storybook/channels';

import type { API_Provider } from '@storybook/types';
Expand Down Expand Up @@ -38,16 +37,6 @@ export interface SubAPI {
* @param handler - The callback function to be called when the event is emitted.
*/
once: (type: string, handler: Listener) => void;
/**
* Emits an event to collapse all stories in the UI.
* @deprecated Use `emit(STORIES_COLLAPSE_ALL)` instead. This API will be removed in Storybook 8.0.
*/
collapseAll: () => void;
/**
* Emits an event to expand all stories in the UI.
* @deprecated Use `emit(STORIES_EXPAND_ALL)` instead. This API will be removed in Storybook 8.0.
*/
expandAll: () => void;
}

export type SubState = Record<string, never>;
Expand Down Expand Up @@ -75,12 +64,6 @@ export const init: ModuleFn<SubAPI, SubState> = ({ provider }) => {
}
provider.channel?.emit(type, data, ...args);
},
collapseAll: () => {
api.emit(STORIES_COLLAPSE_ALL, {});
},
expandAll: () => {
api.emit(STORIES_EXPAND_ALL);
},
};
return { api, state: {} };
};

0 comments on commit e8278ce

Please sign in to comment.