Storybook: The api setQueryParams not working

Created on 29 Oct 2019  路  14Comments  路  Source: storybookjs/storybook

Describe the bug
The method api.setQueryParams not working

To Reproduce

addons.register("storybook/something", (api) => {
  api.setQueryParams({abc: "hello"});
});

Expected behavior
expect api.getQueryParam("abc") to be "hello"

Screenshots
Screen Shot 2019-10-29 at 11 58 34 AM

Code snippets
Screen Shot 2019-10-29 at 11 57 30 AM

System:

"@storybook/addons": "^5.2.0",
"@storybook/react": "^5.2.0",

Additional context
The addon was not working with api.setQueryParams and api.getQueryParam any more
https://github.com/echoulen/storybook-addon-styled-component-theme

addons question / support todo

Most helpful comment

All 14 comments

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

I can confirm that this API is not working

"@storybook/react": "6.0.0-alpha.30"

The queryParam is for the preview, not the manager.

storybook/lib/api is code that only runs on the manager.

So is there a way from my addon panel to set something in the query string? I am using the API in the same way as it is being used in the docs: https://storybook.js.org/docs/addons/api/#apisetqueryparams

Why would you need to set something on the query of storybook's manager?

Hi @ndelangen
For my example, I have to set the active tab in my addon from query params if the user refresh the page

For refreshes you could use the localStorage instead?

the route trigger enable tab is more make sense, I had used this API a long time ago, it's was broken after I upgrade the storybook, so that's why I report the issue.

@echoulen you're 100% correct. The API used to set queries on the manager as well, but when we changed to use a router we removed this behavior so we could have clearer/readable URLs that wouldn't grow to be too long.

I would like to be able to set the URL for sharing purposes. Right now I am unable to do anything to the URL as an addon as it is always cleared

I agree that'd be useful

@ndelangen I see

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aericson picture aericson  路  97Comments

tycho01 picture tycho01  路  76Comments

43081j picture 43081j  路  61Comments

ilias-t picture ilias-t  路  73Comments

bpeab picture bpeab  路  70Comments