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 in true state in URL is ignored #25035

Closed
JReinhold opened this issue Nov 29, 2023 Discussed in #25034 · 4 comments · Fixed by #25950
Closed

[Bug]: Boolean control in true state in URL is ignored #25035

JReinhold opened this issue Nov 29, 2023 Discussed in #25034 · 4 comments · Fixed by #25950

Comments

@JReinhold
Copy link
Contributor

Discussed in #25034

Originally posted by khats November 29, 2023

Summary

When a boolean control is true it is correctly written to the URL, however when reloading the browser the query parameter is ignored and the boolean is converted back to false again. The same happens when you attempt to open the preview iframe.

Reproduction

  1. Open this story for the boolean control, starting in an undefined state: https://next--635781f3500dd2c49e189caf.chromatic.com/?path=/story/blocks-controls-boolean--undefined
  2. Set the boolean to false and reload. See that it correctly stays false.
  3. Set the boolean to true and reload. See that it is now false again.
@JReinhold JReinhold changed the title Boolean control leads inversive in URL [Bug]: Boolean control in true state in URL is ignored Nov 29, 2023
@markallancourtney
Copy link

I can confirm this bug exists.

Query string parameters seem to be negating boolean values by using !true and !false

&args=control-name:!false

@cellog
Copy link

cellog commented Dec 11, 2023

This breaks any boolean or date control if you load the story in a separate tab using
image

We have a decorator that responds to updates in args to force a reload in order to ensure values get reflected. This breaks in the latest storybook, which makes it very impossible to use storybook for development of features that use the args represented by the boolean control

@cellog
Copy link

cellog commented Dec 11, 2023

there is a workaround we can use which is kind of silly but it works:

        {
          options: ["true", "false"],
          mapping: { true: true, false: false },
          description: "arg description",
          control: {
            type: "select",
            labels: { true: "Enabled", false: "Disabled" },
          },
        },

You just have to change the default value for the arg from true to "true" and false to "false"

@vanessayuenn
Copy link
Contributor

same issue as #23623

@JReinhold JReinhold linked a pull request Feb 7, 2024 that will close this issue
8 tasks
@github-project-automation github-project-automation bot moved this from Empathy - Ready for work to Done in Core Team Projects Feb 8, 2024
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.

5 participants