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

Sidebar filters and sidebar tag badges don't co-exist #19

Closed
Sidnioulz opened this issue Nov 18, 2024 · 6 comments · Fixed by #25
Closed

Sidebar filters and sidebar tag badges don't co-exist #19

Sidnioulz opened this issue Nov 18, 2024 · 6 comments · Fixed by #25
Assignees
Labels
question Further information is requested released

Comments

@Sidnioulz
Copy link
Owner

Sidnioulz commented Nov 18, 2024

I had the same issue. I noticed that when removing my sidebar filters in manager.ts, it did show up.

I have a sidebar filter in manager.ts so it won't display my stories with tag 'chromatic-only'

manager.ts
import { addons } from '@storybook/manager-api';

addons.setConfig({
  sidebar: {
    filters: {
      patterns: (item) => {
        // in the sidebar exclude all items with the tag 'chromatic-only'
        return !item.tags?.includes('chromatic-only');
      },
    },
  },
});

Originally posted by @Fedduh in #15 (comment)

@Sidnioulz Sidnioulz added the bug Something isn't working label Nov 18, 2024
@Sidnioulz Sidnioulz self-assigned this Nov 18, 2024
@Sidnioulz
Copy link
Owner Author

Hi @Fedduh, sadly I could not reproduce this issue.

I've added the same sidebar filter config you're using on my local storybook instance on the main branch. Could you please run it and confirm you see the sidebar badges?

Could you please share a repo where sidebar filters trigger the issue so I can investigate it?

@Sidnioulz Sidnioulz added question Further information is requested and removed bug Something isn't working labels Nov 18, 2024
@Fedduh
Copy link

Fedduh commented Nov 19, 2024

It was a bit of a hassle to setup a repo (my own repo is private).
I used some AI to set it up, but it does demostrate the issue. Perhaps it's cause by the Angular version of Storybook?

This is the stackblitz:
https://stackblitz.com/edit/sb1-kd55we?file=.storybook%2Fmanager.ts

If you run it (npm i && npm start) it will show the badge in the sidebar, and on top
image

When you

  • 'restore' the commented code in './storybook/manager.ts' (the sidebar property)
  • restart the application (stop current and npm start)

It will only show on top.
image

Hope this helps you debugging. I could indeed not reproduce the issue in your main branch.

(please ignore the node version warnings.. locally i do use node > v20. But i can't change the node version of Stackblitz)

@Sidnioulz
Copy link
Owner Author

I suspect that addons.setConfig({ sidebar }) erases the whole sidebar object, including renderLabel.

Could you try to keep your filters and add the following?

// .storybook/manager.ts
import { addons } from '@storybook/manager-api'
import { renderLabel } from 'storybook-addon-tag-badges'

const filters = { /* ... */ };

addons.setConfig({
  sidebar: {
    filters,
    renderLabel,
  }
})

@Fedduh
Copy link

Fedduh commented Nov 20, 2024

That indeed fixes it! Thanks :)

@Sidnioulz
Copy link
Owner Author

Yay! Thanks for reporting back. I'll add a more explicit use case in the README so it's easier to spot.

Copy link

🎉 This issue has been resolved in version 1.2.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants