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

Version patch from 7.6.20 #30084

Open
wants to merge 3 commits into
base: release-7-6
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 14 additions & 0 deletions code/lib/preview-api/src/modules/store/csf/prepareStory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@ describe('prepareStory', () => {
expect(tags).toEqual(['component-1', 'component-2', 'story']);
});

it('component tags work if story are do not have tags', () => {
const { tags } = prepareStory(
{ id, name, tags: [], moduleExport },
{
id,
title,
tags: ['component-1', 'component-2'],
},
{ render }
);

expect(tags).toEqual(['component-1', 'component-2', 'story']);
});
EgorBochkarev marked this conversation as resolved.
Show resolved Hide resolved

it('sets a value even if annotations do not have tags', () => {
const { tags } = prepareStory({ id, name, moduleExport }, { id, title }, { render });

Expand Down
10 changes: 9 additions & 1 deletion code/lib/preview-api/src/modules/store/csf/prepareStory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,15 @@ function preparePartialAnnotations<TRenderer extends Renderer>(
// anything at render time. The assumption is that as we don't load all the stories at once, this
// will have a limited cost. If this proves misguided, we can refactor it.

const tags = [...(storyAnnotations?.tags || componentAnnotations.tags || []), 'story'];
const tags = [];

if (storyAnnotations?.tags?.length) {
tags.push(...storyAnnotations?.tags);
EgorBochkarev marked this conversation as resolved.
Show resolved Hide resolved
} else if (componentAnnotations.tags?.length) {
tags.push(...componentAnnotations.tags);
}

tags.push('story');

const parameters: Parameters = combineParameters(
projectAnnotations.parameters,
Expand Down
Loading