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]: Boolean control is not persistent #22679

Closed
Spielboerg opened this issue May 22, 2023 · 7 comments · Fixed by #22807
Closed

[Bug]: Boolean control is not persistent #22679

Spielboerg opened this issue May 22, 2023 · 7 comments · Fixed by #22807

Comments

@Spielboerg
Copy link
Contributor

Describe the bug

As the title suggests, boolean controls are not persistent when the page is reloaded. On the one hand, it logs unnecessarily many warnings and on the other hand, direct links to stories with control values in it cannot be sent to someone else.

See the Reproduction section for more information.

To Reproduce

https://stackblitz.com/edit/github-fbee7n?file=src%2Fstories%2FButton.stories.js

Preparation: Do not use the inline preview but open the preview in a new tab (button on the upper right). Only in this way it is possible for you to see the changes in the URL.

Successful case:

  1. Go to the Button/Primary story
  2. Clear the logs in the browser dev tools
  3. Click on the primary control to change it to false.
    • Notice that &args=primary:!false is added to the URL
    • Notice this warning in the logs:
      Omitted potentially unsafe URL args.
      
      More info: https://storybook.js.org/docs/react/writing-stories/args#setting-args-through-the-url
      
  4. Reload the page
    • Notice the &args=primary:!false is still in the URL and the primary control is set to false
    • Notice that the warning from 3. above is logged again.

Failing case:

  1. Go to the Button/Secondary story
  2. Clear the logs in the browser dev tools
  3. Click on the primary control to change it to true.
    • Notice that &args=primary:!true is added to the URL
    • Notice this warning in the logs:
      Omitted potentially unsafe URL args.
      
      More info: https://storybook.js.org/docs/react/writing-stories/args#setting-args-through-the-url
      
  4. Reload the page
    • Notice the &args=primary:!true is no longer in the URL and the primary control is set to false
    • Notice that the warning from 3. above is logged again.

System

No response

Additional context

No response

@shilman
Copy link
Member

shilman commented Jun 6, 2023

Jiminy cricket!! I just released https://github.com/storybookjs/storybook/releases/tag/v7.1.0-alpha.28 containing PR #22807 that references this issue. Upgrade today to the @next NPM tag to try it out!

npx sb@next upgrade --prerelease

@demeshkin
Copy link

@shilman I don't think the issue is fixed. When passing !true arguments in URL &args=primary:!true it's changes to false in the control.

@NiklasPor
Copy link

We're using buildArgsParam inside some tests which run against our Storybook and it includes the same issue. For now we're required to do some search & replace to remove the ! before true and false which keep storybook from interpreting them correctly.

@MichaelAllenWarner
Copy link

Yes, I see this behavior in my projects as well. The exclamation mark is getting wrongly added to boolean args set from the Controls.

@RJesusTVD
Copy link

Hello,

Any updates on this bug?

Thanks

@Nicolas-Menettrier
Copy link

Same behavior on my project too, I used @NiklasPor suggestion as a quick fix. Does the job

@shilman
Copy link
Member

shilman commented Jan 11, 2024

closing as duplicate to #25035

@shilman shilman closed this as completed Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants