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]: Storybook action logs eventName:{name: eventName, args: false} for false value works with boolean true value #22163
Comments
Do you a have a reproduction repo you can share? If not, can you create one? Go to https://storybook.new or see repro docs. Thank you! 🙏 |
@shilman Goto button stories and click on button. Then check actions tab. |
@shilman Is there any update on this issue? |
This incongruence has bothered my team for a while as well. It would be good to at least know the rationale. A similar thing happens when calling an action handler function and passing no arguments. Sometimes I’ve resorted to wrapping the handler and passing an empty object to keep the log clean, but ideally in this situation the UI would just show the action name without any arguments. |
@shilman Is there any update here? |
I'm encountering this bug as well, any updates? |
I'm also suffering from the same bug. |
A colleague and me at work encountered this problem too. After digging around in the source code, we believe this line is the culprit here:
Any value we pass as argument that evaluates falsey would be replaced by the whole data object, which is exactly what is happening here. Simply replacing the or (||) operator with the nullish coalescing (??) operator should fix the issue. If I find the time this weekend I'll try to create a PR for this issue. |
I had some time today to try this one out. In the test stories included, the old behaviour was easy to replicate by simply randomly flipping a boolean: This also happens with a counter once it would reach 0: With the proposed change, the booleans and numbers would get printed as one would expect: @ndelangen @yannbf sorry for the pings but I saw your names as the code owners for the actions addon. Would such a change be welcome? |
Describe the bug
Hello,
I am having button component which is emitting value as a boolean value.
Storybook shows the value in the action tab as eventName say click then
click:true if value emitted is true but if we are emitting a value false then it logs click:{name: "clicked", args: false}} which is not correct. I tried this with both angular and react project which is not working.
It should emit click:false rather than click:{name: "clicked", args: false}}.
To Reproduce
System
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: