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

[Bug]: Local stories not working when loading external refs #25957

Closed
nilpaco opened this issue Feb 8, 2024 · 6 comments · Fixed by #26304
Closed

[Bug]: Local stories not working when loading external refs #25957

nilpaco opened this issue Feb 8, 2024 · 6 comments · Fixed by #26304

Comments

@nilpaco
Copy link

nilpaco commented Feb 8, 2024

Describe the bug

I'm encountering an issue where the main documentation section of our Storybook project remains indefinitely in the loading state, despite the content having completely loaded. In the video you can see that deleting the preview-loader container the content is shown.

Screen.Recording.2024-02-08.at.12.54.52.mov

The issue appears to be with how Storybook handles the loading of external references that share the same base URL with the stories loaded externally.

Example of conflicting URLs:

The previewInitialized state doesn't get properly updated because the URL matching logic incorrectly impacts the state of an external reference instead of the local story. (see findRef source code):

findRef: (source): any => {
      const refs = api.getRefs();
      return Object.values(refs).find(({ url }: any) => url.match(source));
}

To Reproduce

Not the most elegant way but I've prepared a StackBlitz project that mimics a similar configuration. In this example, you can see that the external references match with the same URL, as previously mentioned.

https://stackblitz.com/edit/github-j9db22?file=.storybook%2Fmain.js

note: You may need to update the base url of the ref object.

System

No response

Additional context

No response

@ndelangen
Copy link
Member

Hello @nilpaco I'm looking into this, however the video cannot be played or downloaded, it seems.

I'm looking at the stackblitz (thank you for including that!), however it's looking different for me:
Screenshot 2024-03-04 at 14 59 41

It's likely because I don't have access to the composed storybook.
Maybe it's switched off due to inactivity, or it's private?

I tried following through to get access, but ran into trouble
Screenshot 2024-03-04 at 15 02 09
Screenshot 2024-03-04 at 15 02 15

Can you assist me in getting this reproduced reliably?

@ndelangen
Copy link
Member

Never mind, I can reproduce this now, in stackblitz.
I'm investigating..

@nilpaco
Copy link
Author

nilpaco commented Mar 4, 2024

Thank you, @ndelangen! Sorry for the oversight. Let me know if you need anything from me. I've tried different fixes, but any attempt seems to either break something else or fall short.

@ndelangen
Copy link
Member

I'm on the case!

@ndelangen
Copy link
Member

I have found a solution/fix and will open a PR soon! 🎉

@nilpaco
Copy link
Author

nilpaco commented Mar 5, 2024

thank you @ndelangen for the work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants