-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Core: Add 'mapping' to support complex arg values #14100
Conversation
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.
does this actually fix the bug in #12613? or just in the case where the user provides a mapping?
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.
Good start!
Definitely need a test in story_store.test.js
No it doesn't. It logs a warning when you try to use an object as value, and suggest to use a mapping, but the actual bug remains (which I think we can leave in, since we're saying it's not supported). |
Done. |
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.
Looking great @ghengeveld 💯
Note I reopened the original issue #13888 because we changed our minds on the approach. In addition to The |
useEffect(() => { | ||
if ( | ||
Object.values(rows).some(({ control: { options = {} } = {} }) => | ||
Object.values(options).some((v) => !['boolean', 'number', 'string'].includes(typeof v)) |
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.
@ghengeveld after upgrading to latest beta I'm getting this error: Uncaught TypeError: _ref$control is null
Issue: #13888
Related: #12613
What I did
This introduces a
mapping
property for fields inargTypes
, to allow the use of complex arg values. It looks like this:This works on any control type, but makes most sense when used with a radio/select type. Control options must be simple strings so they can be serialized and synced to the URL. Control options can still be defined as an object, but the only use case is if you want a custom select label that may not be serializable (e.g. outside the
[a-z0-9 _-]
range).How to test
If your answer is yes to any of these, please make sure to include it in your PR.