-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
[Bug]: Adding a decorator breaks Show Code
view
#21456
Comments
Show Code
view.Show Code
view.
Show Code
view.Show Code
view
Could you try to set the following code in your export const parameters = {
docs: {
source: {
excludeDecorators: true,
},
},
}; This excludes the decorators from the |
Thanks for your suggestion @valentinpalkovic! |
Hi @shilman, |
Storybook changes: - Update Storybook to v`7.0.0` - Update `preview.tsx` to use default export - https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#default-export-in-previewjs - Remove `--no-manager-cache` flag from storybook build as it no longer exists (broke the build) - Add new local script `storybook:preview` to locally develop with docs view (same nav structure as release build) - Remove `preview-head.html` as the font source has been deactivated and the TS hack doesn't appear needed - Update all titles to not use string literals - https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#string-literal-titles - Delete constants used for titles as they are no longer usable - Fix sort order to not use constants - Remove usage of `withDesign` and `figmaEmbed` - Broken with update. Discussed with Kaizen team and we would prefer it gone instead. - Remove `storybook-addon-designs` (plugin for this feature) - Fix stories using imported markdown - https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#importing-plain-markdown-files-with-transcludemarkdown-has-changed - Update type `ComponentMeta` to `Meta` - https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#componentstory-componentstoryobj-componentstoryfn-and-componentmeta-types-are-deprecated - Update types `ComponentStory` and `Story` to `StoryFn` - https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#componentstory-componentstoryobj-componentstoryfn-and-componentmeta-types-are-deprecated - Replace type `DecoratorFunction` with `Decorator` - https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#renamed-decoratorfn-to-decorator - Move query decorator from global to `FilterMultiSelect` `Async` story - Exclude decorators from code snippets - storybookjs/storybook#21456 (comment) - Replace usages of `ArgsTable` with `Controls` - https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#argstable-block - Wrap examples that do not live within a `Canvas` with `Unstyled` - https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#default-docs-styles-will-leak-into-non-story-user-components - Update `.stories.mdx` files to `.mdx` - https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#mdx-docs-files - Update local dev with story filtering to also search for MDX files - Refactor default story paths to use globs - Update Tailwind docs to work with the new `<Canvas>` structure (using `of` and referencing stories instead of `children`) - https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#canvas-block - Fix `Paragraph` story `Body Strong` example - Fix most warnings/errors in the console - Change all functional components to not use default export, and fix exports for types (as args table missing props or controls) - Add missing `key`s to mapped components - Change `Paragraph` tag to `div` where it was wrapping elements which should not sit within a `p` (eg. `ul`) - Use `import` instead of `require` - Update import statement for storybook backgrounds - Reorder nav structure (#3349) - Group Modals together - Add theming (#3354) - Remove extractComponentDescription as notes are deprecated - https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#description-block-parametersnotes-and-parametersinfo - Add table of contents to docs (#3348) - Hide stickersheets in the Stickersheets story category (#3348) - Add new docs template (#3350) - Cleaned up Color Tokens stories - Add `LinkTo` component for navigation to relative paths - Add styles for links Other changes: - Delete `isEnabled` function as it was for Elm - Remove Google Tag Manager - Delete old READMEs which were used for the site (not used here) --------- Co-authored-by: Geoffrey Chong <gyfchong@users.noreply.github.com> Co-authored-by: Natalie Loyzaga <48232362+NatalieLoyzaga@users.noreply.github.com>
I have the same issue but only when I am doing something like the following: {/** When passing props like below, includes the decorator code */}
<Story
{...context}
args={{ ...context.args, animationTriggerRef: buttonRef }}
/>
{/** Without passing any props, works as expected */}
<Story /> Full context: export const TriggerWithRef = {
args: {
className: "h-10 w-10",
animationTriggerEvent: "hover",
},
parameters: {
controls: { exclude: ["animate"] },
},
decorators: [
(Story, context) => {
const buttonRef = useRef();
return (
<div>
<button className="mb-5" ref={buttonRef}>
hover me
</button>
<Story
{...context}
args={{ ...context.args, animationTriggerRef: buttonRef }}
/>
</div>
);
},
],
}; Adding |
I have exactly the same issue as @roymrinmoy (same code almost) and doing the idea of @valentinpalkovic also didn't fix the issue. When changing the args from a Story in a decorator, it breaks the show code. |
This issue is a duplicate of #21649. In summary:
|
For anyone encountering a similar issue when using @storybook/angular I have opened this issue #25147. |
Describe the bug
When adding a decorator in the Preview file, the
Show Code
view in the Docs View is breaking.Show Code
without Decorator:Show Code
with Decorator:Instead of showing the component name with computed args,
<No Display Name />
is shown.To Reproduce
Repo: https://github.com/MarcusNotheis/sb-code-repro
Deployed: https://marcusnotheis.github.io/sb-code-repro/?path=/docs/example-button--docs
To reproduce:
yarn
yarn storybook
and open theButton Docs
story.Show Code
Panel and see the error.decorators
array from the preview file, then theShow Code
panel is displayed correctly:https://github.com/MarcusNotheis/sb-code-repro/blob/5f94ba62da2083cc89c30ba5122192a10fee1fe3/.storybook/preview.tsx#L27
System
Additional context
No response
The text was updated successfully, but these errors were encountered: