question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

API.setQueryParams not works as expected

See original GitHub issue

Describe the bug Expected URL updated when api.setQueryParams get called.

To Reproduce Steps to reproduce the behavior:

  • In any add-on tooltip component, where get access with storybookAPI, call storybookAPI.setQueryParams({ foo: 'bar' }).

Expected behavior URL change to, for example: http://localhost:6006/?path=/story/test&foo=bar.

System:

  • OS: MacOS Mojave
  • Device: MacBook Air 2013-mid
  • Browser: Chrome 72
  • Framework: React 16.8.1
  • Version: v5.0.0-beta.2

Additional context Related #5271

if call the following immediately

console.log(api.getQueryParam('foo')) // `bar` printed

Therefore, it is working (previously in alpha.11 is not working though), but the URL is not changing. Also, by directly change the URL state like http://localhost:6006/?path=/story/test&foo=bez. 'bez' get printed correctly, but the URL changed to http://localhost:6006/?path=//story/test. It added additional slash after ?path mysteriously… And if refresh the page, no 'bez' get printed.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:34 (21 by maintainers)

github_iconTop GitHub Comments

8reactions
uriel-sfcommented, Mar 26, 2019

If the API is called set/get query params, you kinda expect it to work that way 😃 How about instead of changing its behavior, this API is slowly deprecated over several releases? That would probably be better for devs expecting the API to work like it did before (myself included).

7reactions
leoylicommented, Feb 15, 2019

@tmeasday Here gives me some confusions, does any reason we don’t want the URL keep the query parameter?! Ideally, I would like to share the URL to other people, let’s say for designer. That would be super useful for our communication.

The biggest reason for me to have query in URL is for testing. I have add-on work for this (e.g. &themes=dark&languages=english), this gives us the ability to mock a particular environment state that the component is reacted to (i.e theming or language). It would be nice we can have this kept when we “open the component into a new tab”, then we can copy past URL without manually typing those parameters.

In our team, we want to have at least 1 story per dummy components and they are smartly knobbed and auto-generated. For some special variants (i.e. component specific) we will have more granular-defined stories to document some important use case so we can cherry-pick them for smoke testing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

API.setQueryParams not works as expected #5533 - GitHub
Describe the bug Expected URL updated when api.setQueryParams get called. To Reproduce Steps to reproduce the behavior: In any add-on ...
Read more >
Angular 4 HttpClient Query Parameters - Stack Overflow
The first snippet is wrong. let params = new HttpParams(); params.set(...) won't work as expected. See stackoverflow.com/questions/ ...
Read more >
Building requests | Postman Learning Center
You can send requests in Postman to connect to APIs you are working with. Your requests can retrieve, add, delete, and update data....
Read more >
RESTMessageV2 substitute parameter in URL - ServiceNow
Some API calls have parameters in URL ... does not work and alternative method setQueryParameter will append the value to url.
Read more >
AssignMessage policy | Apigee Edge
This is expected behavior for most policies. ... If you do not specify <AssignTo> , the policy acts on the default request or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found