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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to handle single quote in stories? #31

Closed
jibees opened this issue Apr 13, 2021 · 5 comments
Closed

How to handle single quote in stories? #31

jibees opened this issue Apr 13, 2021 · 5 comments

Comments

@jibees
Copy link

jibees commented Apr 13, 2021

Hi
Thanks a lot for your library, which is very useful for a React developer, newly involved into a Rails project 馃檹

I'm facing an issue with single quote escaping... Which I was able to reproduce with the https://github.com/jonspalmer/view_component_storybook_example project (and mine obviously)

When I try to add a single quote character as an example for the title attribute of the TestComponent like this:

diff --git a/test/components/stories/test_component_stories.rb b/test/components/stories/test_component_stories.rb
index 09275ba..efd6fb7 100644
--- a/test/components/stories/test_component_stories.rb
+++ b/test/components/stories/test_component_stories.rb
@@ -26,7 +26,7 @@ class TestComponentStories < ViewComponent::Storybook::Stories
 
   story(:with_long_title) do
     controls do
-      title 'This is a really long title to see how the component renders this'
+      title "This is a really long titl'e to see how the component renders this"
     end
     content do
       "Help me please"

I got an error into my console:

index.js:47 Unexpected error while loading ./stories/test_component.stories.json: Error: Module parse failed: Unexpected token (49:37)
File was processed with these loaders:
 * ./node_modules/@storybook/server/dist/cjs/server/loader.js
You may need an additional loader to handle the result of these loaders.
| };
| with_long_title.args = {
>   title: 'This is a really long titl'e to see how the component renders this'
| };
| with_long_title.argTypes = {

which show, in an obvious way, an escape issue around ' character.
I'm wondering how to handle it?

@jonspalmer
Copy link
Owner

Interesting. Do you think you could share this as a failing test in a PR on this repo?

@jibees
Copy link
Author

jibees commented Apr 13, 2021

Interesting. Do you think you could share this as a failing test in a PR on this repo?

this repo: https://github.com/jonspalmer/view_component_storybook_example? (or https://github.com/jonspalmer/view_component_storybook)

What do you mean by failing test? I can create a PR with failing story.

@jibees
Copy link
Author

jibees commented Apr 13, 2021

@jonspalmer I've created a PR with failing story: jonspalmer/view_component_storybook_example#14

@jonspalmer
Copy link
Owner

Thanks for the PR. Turns out this is a bug in Storybook Server. I'll need to add the fix for that and figure out what the release vehicle looks like there.

@jonspalmer
Copy link
Owner

This is fixed as of the changes in Storybook

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

No branches or pull requests

2 participants