-
-
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
Addon-controls: Fix update logic for argTypes with custom names #11704
Addon-controls: Fix update logic for argTypes with custom names #11704
Conversation
My sense is that |
7309560
to
beccf74
Compare
beccf74
to
28b64b6
Compare
@@ -32,20 +32,20 @@ export const ArgControl: FC<ArgControlProps> = ({ row, arg, updateArgs }) => { | |||
}, [isFocused, arg]); | |||
|
|||
const onChange = useCallback( | |||
(argName: string, argVal: any) => { | |||
(argVal: any) => { |
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.
I don't see any reason for the callback to have the key. Before we were ignoring it anyway. The Controls shouldn't need to know this detail.
); | ||
|
||
const onBlur = useCallback(() => setFocused(false), []); | ||
const onFocus = useCallback(() => setFocused(true), []); | ||
|
||
if (!control || control.disable) return <NoControl />; | ||
|
||
const props = { name, argType: row, value: boxedValue.value, onChange, onBlur, onFocus }; | ||
// row.name is a display name and not a suitable DOM input id or name - i might contain whitespace etc. | ||
// row.key is a hash key and therefore a much safer choice |
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.
@shilman and I discussed adding a key
prop (which would actually have to be argKey
as key
is a React reserved property). However, with the onChange adjustment its mostly unnecessary. We're really intending to hand in something that can be used as a DOM Input id/name. This makes for a much smaller change
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.
LGTM! Thanks for the fix @jonspalmer!!
Controls with a name don't update when changed. Failing test case against Official Storybook.
What I did
name
prop.How to test
/?path=/story/controls-boolean--basic
/?path=/story/core-args--passed-to-story