-
-
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
Add readonly option #14077
Add readonly option #14077
Conversation
…s (ignoring Object, etc.) + add warning when using both disable/readonly on the same input (disable wins)
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. Can you please add some examples to official-storybook
? And some documentation to
https://github.com/storybookjs/storybook/blob/next/docs/essentials/controls.md
The current implementation doesn't work on When I add a console.log in export const TextControl: FC<TextProps> = ({
name,
value,
onChange,
onFocus,
onBlur,
readOnly,
}) => {
console.log('TextControl readOnly', readOnly) // Here, displays "true"
const handleChange = (event: ChangeEvent<HTMLTextAreaElement>) => {
onChange(event.target.value);
}; But it only does so when clicking on the "Docs" tab, not on the "Canvas" tab. |
@shilman Documentation is done, could you look at the implementation and let me know if you notice anything wrong? (it's still not working) |
@@ -9,6 +9,7 @@ export interface ControlProps<T> { | |||
onChange: (value: T) => T | void; | |||
onFocus?: (evt: any) => void; | |||
onBlur?: (evt: any) => void; | |||
readOnly?: boolean; |
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 doesn't look right to me, it fixes TS types in the various control option components, but I'm not sure it's correct.
Also, if it's correct, the disable
property should be added there, too.
Sure, I'll take a look today! |
In light of #13890, shouldn't this property be one level up? argTypes: {
foo: {
table: { disable: true }, // deprecated
disable: true, // the new way to disable (hide) an arg
control: { readOnly: true }, // implemented in this PR
readonly: true // I suggest we do this instead
}
} I favor |
@ghengeveld I agree about the Does the And, same goes for |
I had a discussion with @shilman about this, and we concluded that my earlier suggestion is the right way to go. For this PR, that means:
We'll deal with |
I feel like I should probably wait for #13890 to be merged. I'm glad TS types are being improved, it'll be easier to understand. |
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
@Vadorequest Thank you so soo much for this PR! We're really appreciative of any PR we get, because we know it takes a lot of time, effort and energy from contributors. This feature seems like something we want. This has been in draft for over a year now, and the codebase has changed a lot since then, and with the upcoming changes for 7.0 that work would probably be even more complex. Again, we truly appreciate your time, energy and skill that you put into this PR! Thank you. I'm sorry for closing. |
Thanks for the heads-up - I had totally forgotten about this. I won't work on it again, someone else should take the lead if you want this to be implemented :) |
I understand this PR has closed, but have you ever thinking anything about this requirement? I will inspect the PR and if I wanna volunteer, I will inform you. |
Hi, |
Issue: #14048
What I did
How to test
If your answer is yes to any of these, please make sure to include it in your PR.