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.

Array argument is transformed in Object after refreshing the page with a pre-defined value set in the URL

See original GitHub issue

Describe the bug

Given I have a component with an argument “correctAnswers” which is configured as a “string[]” And in the “Controls” panel I can see that the control value is initially an empty array And I manually modify the control value via the “Controls” panel adding an element to it (“answer1”) And I see that in the browser URL the control value change is tracked as follows: “&args=correctAnswers[0]:answer1” When I refresh the page with the updated URL Then I see that the control value becomes an Object containing a single key with the value I added before (“answer1”) And my component breaks because it receives an Object instead of an Array for the specific control

To Reproduce

Reproduction deployed with Chromatic: https://60e41a0b495b7b003b17750c-mxahjzabca.chromatic.com/?path=/story/bug--bug-case

Please follow the description Gherkin to reproduce the issue.

The reproduction can be cloned from the following repo: https://github.com/marcodellovo-dcbo/my-storybook-reproduction.git

System

System:
    OS: macOS 10.15.7
    CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
  Binaries:
    Node: 10.15.1 - ~/.nvm/versions/node/v10.15.1/bin/node
    npm: 7.17.0 - ~/Documents/Docebo/Dev/repos/sdk/training-elements/node_modules/.bin/npm
  Browsers:
    Chrome: 91.0.4472.114
    Firefox: 88.0.1
    Safari: 14.0.3
  npmPackages:
    @storybook/addon-a11y: ~6.3.1 => 6.3.1
    @storybook/addon-actions: ~6.3.1 => 6.3.1
    @storybook/addon-console: ~1.2.3 => 1.2.3
    @storybook/addon-docs: ~6.3.1 => 6.3.1
    @storybook/addon-essentials: ~6.3.1 => 6.3.1
    @storybook/addon-links: ~6.3.1 => 6.3.1
    @storybook/angular: ~6.3.1 => 6.3.1
    @storybook/theming: ~6.3.1 => 6.3.1

Additional context

There are no errors in the console and I haven’t defined any custom configuration for the specific control via “ArgTypes”.

Initial state of the control when there isn’t any pre-defined value in the browser URL

Screenshot 2021-07-05 at 18 21 15

State of the control when there’s a pre-defined value for it in the browser URL

Screenshot 2021-07-05 at 18 22 53

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
shilmancommented, Jul 6, 2021

thanks for the repro @marcodellovo-dcbo ! that def looks like a 🐛

1reaction
marcodellovo-dcbocommented, Jul 6, 2021

@shilman I’ve updated the description including the link to the deployed reproduction and the repo in case you need to check the code.

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change URL parameters and specify defaults using JavaScript
what I need is to be able to change the 'rows' url param value to something i specify, lets say 10. And if...
Read more >
Oracle Visual Builder Page Model Reference
Array Variables​​ Variables can represent arrays. Arrays are defined the same way as objects. However, in this case, the object type is inside...
Read more >
Array | Apple Developer Documentation
If you need an array that is preinitialized with a fixed number of default values, use the Array(repeating:count:) initializer.
Read more >
TypeError: Reduce of empty array with no initial value
The JavaScript exception "reduce of empty array with no initial value" occurs when a reduce function is used.
Read more >
Rewrites - next.config.js
In contrast, redirects will reroute to a new page and show the URL changes. ... has is an array of has objects with...
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