Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core: Remove collapseAll and expandAll methods #25486

Merged
merged 1 commit into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: {} };
};