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

fix: docs error toLowerCase #756

Merged
merged 2 commits into from
Oct 16, 2021

Conversation

edoardolincetto
Copy link
Contributor

@edoardolincetto edoardolincetto commented Oct 14, 2021

Fixes #751

PR Checklist

  • My branch is up-to-date with the Upstream master branch.
  • The unit tests pass locally with my changes (if applicable).
  • I have added tests that prove my fix is effective or that my feature works (if applicable).
  • I have added necessary documentation (if appropriate).

Short description of what this resolves:

Not passing the story prop causes the following error: Cannot read properties of null (reading 'toLowerCase'); passing some illegal characters to the LinkTo component (@storybook/addon-link) breaks the link;

Changes proposed in this Pull Request:

  • In the MDX files, replace (where possibile) LinkTo with the standard Markdown syntax to create links to other stories, documentation pages and sections.
  • Where LinkTo is needed, add the story prop and remove illegal characters.

@vercel
Copy link

vercel bot commented Oct 14, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/dip-trasformazione-digitale/design-react-kit/CMWUUUyZwyHHZbBxLcWLbm25kprG
✅ Preview: https://design-react-kit-git-fork-ed-46c8b4-dip-trasformazione-digitale.vercel.app

@dej611
Copy link
Member

dej611 commented Oct 15, 2021

Do you have any source about the problem? Having a list of the "illegal" characters would be useful.
Also, what about linkTo function? Is that affected of the same problem?

@edoardolincetto
Copy link
Contributor Author

We need to link specific anchors of other stories, but unfortunately, doing that shows two issues:

  1. Without a story prop (passed to LinkTo), the toLowerCase error is thrown in the console.
    Addons-links with MDX storybookjs/storybook#10846
  2. Adding the story prop and, at the same time, linking to a specific anchor using the path query string breaks the link (because Storybook sanitizes strings replacing the # character with a -).
    Here's the full list of characters that Storybook replaces with a -.

Anyway, I've replaced the LinkTo (with the standard Markdown link syntax) only in the Markdown lines, not the JSX ones. I think this makes the docs cleaner than using the linkTo function.
That's how, in my opinion, it should be:

  • Use the standard Markdown link syntax in the Markdown parts of the code;
  • Use the LinkTo component in the JSX parts of the code.

Copy link
Member

@dej611 dej611 left a comment

Choose a reason for hiding this comment

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

Great job 👍 and thanks for all the info 🎉 : now they are documented in case of further investigations.

@dej611 dej611 merged commit b8f43a3 into italia:master Oct 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Docs error in some docs stories
2 participants