-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
Fix/17063/avoid undefined args #17973
Conversation
Preview: Don't hide the story while preparing
…-no-inline Don't render with `modernInline` if `inlineStories` is `false`
…automigrate CLI: Fix mainjsFramework automigrate
…ion-fix Addon-docs: Fix transclusion crash on webpack rules without test field
Angular: Fix tsConfig paths not resolving for Angular >=12.2
Bump lodash to 4.17.21
Angular: Fix incorrect log
Fix typo in Annotation section
Core: Avoid framework imports from core/client
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 471fb5c. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this branch ✅ Successfully ran 1 targetSent with 💌 from NxCloud. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank for fixing this important issue, @evont! And with your very first contribution. 👏
@shilman @tmeasday — This change seems sound to me, but the args code in general is likely quite nuanced and I think it would benefit from you taking a look as well. Also, is it OK that this PR is against main
instead of next
?
@evont — I'd do this myself, but I cannot push to your fork's branch. Can you please add this story, to the export const TestUndefinedArgs = Template.bind({});
TestUndefinedArgs.args = {
first: 'Bob',
last: 'Miller',
foo: 'bar',
};
TestUndefinedArgs.argTypes = {
first: {
options: ['Bob', 'Alice'],
},
last: {
options: ['Miller', 'Meyer'],
},
foo: {
control: { type: 'text' },
},
}; That will allow maintainers to easily test your change (use the same repro steps as the linked issue) in the deployed Storybook. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution @evont. Can you please add test case(s) that demonstrate the original problem?
@@ -101,7 +101,8 @@ export const validateOptions = (args: Args, argTypes: ArgTypes): Args => { | |||
const isValidArray = isArray && invalidIndex === -1; | |||
|
|||
if (args[key] === undefined || options.includes(args[key]) || isValidArray) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check for args[key] === undefined
seems a little pointless if we later do if (key in args)
. Do we understand why the code was there in the first place? We should get rid of it, and perhaps figure that out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or does it remain here to avoid the warning lower down?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
key in args
is not the same as the check for args[key] === undefined
, caused if the key
is existed in args
, but is set as undefined
, it shall pass the if
condition. In the other hand, if the key
is not existed in args
, the value will still be undefined
, then it will pollute the acc
and turn out the param will become undefined
Sure, with pleasure, I have added it and push it to the branch, except I added |
Issue: #17063
What I did
fix args values not present in url are casted to !undefined for controls of type select and radio issue
How to test
If your answer is yes to any of these, please make sure to include it in your PR.