Skip to content

Core: Add default selection for tags in main config#32373

Merged
yannbf merged 5 commits into
yann/test-fn-prototypefrom
yann/add-tags-preset-to-main
Sep 2, 2025
Merged

Core: Add default selection for tags in main config#32373
yannbf merged 5 commits into
yann/test-fn-prototypefrom
yann/add-tags-preset-to-main

Conversation

@yannbf

@yannbf yannbf commented Sep 2, 2025

Copy link
Copy Markdown
Member

Finalizes #32268

What I did

  • Enhanced Sidebar component to utilize tag presets for managing selected tags.
  • Updated TagsFilter to initialize selected tags based on tag presets.
  • Modified TagsFilter stories to reflect new tag preset functionality.

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>

Greptile Summary

Updated On: 2025-09-02 13:45:35 UTC

This PR implements tag preset functionality to allow users to control which tags are selected by default in the Storybook sidebar through main.ts configuration. The changes introduce a new defaultSelected property to the TagOptions interface, enabling users to specify initial tag selection state in their configuration.

The implementation follows a clear data flow: users configure tag options with defaultSelected: true in their main.ts file, which gets processed by the common preset system and made available via global.TAGS_OPTIONS. The Sidebar component transforms this configuration into tagPresets and passes it to the TagsFilter component. The TagsFilter component then uses a new useEffect hook to automatically select tags based on the preset configuration when the component mounts or when tagPresets change.

The changes also update the TagsFilter stories to demonstrate the new functionality, including a new story that tests the inversion feature. A documentation comment was added to the common preset to clarify the intended ordering for default selected tags, ensuring users can still override preset configurations.

This feature addresses issue #32268 and provides a more structured approach to tag filtering UX, moving away from relying solely on hardcoded initial selected tags to a configurable preset system that integrates with Storybook's existing configuration architecture.

Confidence score: 2/5

  • This PR has a critical implementation issue that could break existing functionality and introduce bugs
  • Score lowered due to the TagsFilter useEffect overwriting initialSelectedTags prop without consideration and potential null safety issues
  • Pay close attention to code/core/src/manager/components/sidebar/TagsFilter.tsx which contains the problematic logic

…nent

- Introduced 'play-fn' and 'test-fn' tags with default selection in common-preset.
- Enhanced Sidebar component to utilize tag presets for managing selected tags.
- Updated TagsFilter to initialize selected tags based on tag presets.
- Modified TagsFilter stories to reflect new tag preset functionality.
@yannbf yannbf self-assigned this Sep 2, 2025
@yannbf yannbf added ui tags ci:normal Run our default set of CI jobs (choose this for most PRs). labels Sep 2, 2025

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 files reviewed, 2 comments

Edit Code Review Bot Settings | Greptile

Comment on lines +67 to +71
useEffect(() => {
const tags = Object.keys(tagPresets);
const selectedTags = tags.filter((tag) => tagPresets[tag].defaultSelected);
setSelectedTags(selectedTags);
}, [tagPresets]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: This useEffect completely ignores initialSelectedTags and overwrites any initially selected tags. Consider merging both sources or prioritizing one over the other.

Comment thread code/core/src/manager/components/sidebar/TagsFilter.tsx Outdated
@nx-cloud

nx-cloud Bot commented Sep 2, 2025

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 8d18419

Command Status Duration Result
nx run-many -t build --parallel=3 ✅ Succeeded 1m 8s View ↗

☁️ Nx Cloud last updated this comment at 2025-09-02 16:16:46 UTC

@storybook-app-bot

storybook-app-bot Bot commented Sep 2, 2025

Copy link
Copy Markdown

Package Benchmarks

Commit: b50b279, ran on 2 September 2025 at 15:17:00 UTC

The following packages have significant changes to their size or dependencies:

@storybook/builder-webpack5

Before After Difference
Dependency count 198 198 0
Self size 80 KB 80 KB 0 B
Dependency size 31.43 MB 31.45 MB 🚨 +17 KB 🚨
Bundle Size Analyzer Link Link

@storybook/ember

Before After Difference
Dependency count 203 203 0
Self size 28 KB 28 KB 0 B
Dependency size 28.17 MB 28.18 MB 🚨 +17 KB 🚨
Bundle Size Analyzer Link Link

@storybook/nextjs

Before After Difference
Dependency count 538 538 0
Self size 903 KB 903 KB 0 B
Dependency size 59.34 MB 59.35 MB 🚨 +17 KB 🚨
Bundle Size Analyzer Link Link

@storybook/react-webpack5

Before After Difference
Dependency count 286 286 0
Self size 25 KB 25 KB 0 B
Dependency size 43.75 MB 43.77 MB 🚨 +17 KB 🚨
Bundle Size Analyzer Link Link

@storybook/server-webpack5

Before After Difference
Dependency count 210 210 0
Self size 17 KB 17 KB 0 B
Dependency size 32.70 MB 32.72 MB 🚨 +17 KB 🚨
Bundle Size Analyzer Link Link

@storybook/preset-react-webpack

Before After Difference
Dependency count 177 177 0
Self size 24 KB 24 KB 0 B
Dependency size 30.59 MB 30.61 MB 🚨 +17 KB 🚨
Bundle Size Analyzer Link Link

@yannbf yannbf force-pushed the yann/add-tags-preset-to-main branch from b50b279 to 24253d8 Compare September 2, 2025 15:39
Comment thread code/core/src/core-server/presets/common-preset.ts Outdated
@yannbf yannbf merged commit 15e965e into yann/test-fn-prototype Sep 2, 2025
4 of 8 checks passed
@yannbf yannbf deleted the yann/add-tags-preset-to-main branch September 2, 2025 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:normal Run our default set of CI jobs (choose this for most PRs). tags ui

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant