-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
Controls: Properties with controls use name of the assigned variable as their value #16865
Comments
Here is a complementary case, for a component implementing ControlValueAccessor, we have class properties for onChange: any = () => {};
onTouch: any = () => {}; Clicking on the component will result in error Disabling the control does not help: parameters: {
controls: {
disable: true
},
}, We need to exclude explicitly wrongly-interpreted properties: parameters: {
controls: {
disable: true,
exclude: ['onChange', 'onTouch'],
},
}, Same goes with using QueryList properties: @ContentChildren(RadioButtonComponent)
buttons: QueryList<RadioButtonComponent> = new QueryList<RadioButtonComponent>(); which will results in error: ERROR Error: Error trying to diff 'new QueryList<RadioButtonComponent>()'. Only arrays and iterables are allowed
// or
ERROR TypeError: this.buttons.forEach is not a function (FWIW, it was tested with Compodoc 1.1.15 and 1.1.16 and Storybook 6.4.5) |
@astik indeed having to exclude them everywhere (especially in a large monorepo) is tedious, bloats stories and removes the properties/methods from the documentation. Inaddition I can also see problems arising with methods since these also receive controls since Storybook 6.4. |
I had the problem in the 6.3 branch already, it was fixed (also in the 6.3 branch) by a combination of upgrading Storybook and / or Compodoc ... still i can't remember when it occurs precisely. |
@pvds thanks for the clean repro! (haven't actually run it yet, but super useful .. shouldn't be hard to fix, hopefully in the next day or two) |
I've tried to debug the issue in your code base on my local machine but it's quite a deep dive and I'm not familiarized enough with the storybook repo. @shilman do you have a status update? |
@shilman, any updates about that issue? Thanks! |
Will try to look at it today @fdabrowski @pvds |
@rothsandro as you've mentioned #17004 and #16959 are also related issues. Maybe good to note is that from what I have tested the issues started since Storybook 6.4 which renders controls for properties and methods too. Without the controls Storybook doesn't 'hijack' the values. |
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! |
According to #17004 it seem linked with the docs addon |
@shilman do you have an update on when you plan to fix this? |
Also waiting for a fix, as the majority of the component stories in our design system are now broken. Experiencing issues with enum properties, as well as errors this. is not a function, as @astik mentions. |
Seems to be related to compodoc because if I run compodoc with these flags --disablePrivate --disableInternal the private and internal flagged properties does not become strings. |
Any updates on this? I am in the process of Nrw/Nx/Angular 13 migration and it is using storybook I am already using the |
@shilman as @amaino states in #17362 (comment) the issue is caused by the removal of Using storybook 6.4.18 I changed the compiled I know The PR (#17353) by @amaino basically replaces @shilman as the root cause seems clear now could you look into resolving this regression? PS. considering the user experience I do not see any benefit in rendering controls for |
@pvds Yes my understanding is that the proper fix is to remove the controls altogether for those values, not to re-introduce the |
If I understand you correctly you mean remove controls for Output, Properties snd Methods and that I agree with mostly as there could be scenarios were you would want to access public properties that are not inputs. But you would still need to use eval for inputs to get corect default values on the controls at least with how it is implemented today or am I missing something? |
@amaino you are correct that only removing controls for for When I have some time i'll update my reproduction examples with As Storybook 6.3 does not work with Angular 13 esm modules I cannot wait anymore with upgrading to Storybook 6.4 so I've patched the
NB this is a rudimentary patch which does not remove controls for |
May I know when will this issue be fixed, as it is impacting my storybook components? The existing components of my project have several attributes. I agree with the above suggestion, there is no need of displaying Outputs, Properties and Methods in the controls addon. |
Related to this point around only considering inputs, the only way we found to unblock ourselves on the latest storybook + Angular on a particular client project was to apply the following patch in the short term: @storybook+addon-docs+6.4.19.patch diff --git a/node_modules/@storybook/addon-docs/dist/esm/frameworks/angular/compodoc.js b/node_modules/@storybook/addon-docs/dist/esm/frameworks/angular/compodoc.js
index 25e13af..a09d519 100644
--- a/node_modules/@storybook/addon-docs/dist/esm/frameworks/angular/compodoc.js
+++ b/node_modules/@storybook/addon-docs/dist/esm/frameworks/angular/compodoc.js
@@ -287,7 +287,7 @@ var resolveTypealias = function resolveTypealias(compodocType) {
export var extractArgTypesFromData = function extractArgTypesFromData(componentData) {
var sectionToItems = {};
- var compodocClasses = ['component', 'directive'].includes(componentData.type) ? ['propertiesClass', 'methodsClass', 'inputsClass', 'outputsClass'] : ['properties', 'methods'];
+ var compodocClasses = ['component', 'directive'].includes(componentData.type) ? ['inputsClass'] : ['properties', 'methods'];
compodocClasses.forEach(function (key) {
var data = componentData[key] || [];
data.forEach(function (item) { |
Only reasonable solution which worked for me was to remove the "component" property of the story definition and to make sure the component is included in the declarations (or in a the declarations of an imported module) as mentioned by someone on a related issue. |
I can confirm removing the component property of the story definition also works for me without the need for disabling the docs addon |
@salmoro Who ? I'll go with the patch and search for alternatives to Storybook |
Just want to chime in that I also see this affecting Stories in my projects. In particular this breaks RxJS Observable pipelines. |
@swiner-dlpx Oh jeez. THANK YOU! THAT'S why my component is getting errors. (I'm in middle of migrating from v5 Knobs to v6 Controls, and I couldn't for the life of me figure out what I was doing wrong.... Turns out that like you said, it's getting confused because I have a string attached to my My exact error was:
And, in case anyone else comes here from google, this fixed it:
|
Great Caesar's ghost!! I just released https://github.com/storybookjs/storybook/releases/tag/v7.0.0-alpha.57 containing PR #19935 that references this issue. Upgrade today to the
Closing this issue. Please re-open if you think there's still more to do. |
@shilman Will this get backported into v6.x? v7 is still in alpha..... |
@EliezerB123 mind testing the beta? If folks here can confirm that the fix works, I'll investigate porting it back to 6.5 |
Any update on how to do this??? |
The bug
Since storybook 6.4 properties also render a control.
When assigning an
enum
to aproperty
thedefaultValue
is interpreted as astring
instead of anenum
.This breaks my components since it receives the name of the enum as a string instead of the enum itself.
To Reproduce
Storybook 6.4.3
With properties using controls the default value becomes a string containing the name of the assigned variable
https://github.com/pvds/storybook-repro-controls-property-bug
https://61a7c73e0e1dc3004a668f13-medaxqhpau.chromatic.com/?path=/story/reproduction-property-control-bug--basic
Storybook 6.3.12
Without properties using controls it works as expected
https://github.com/pvds/storybook-repro-controls-property-bug/tree/test/storybook-6.3.12
https://61a7c73e0e1dc3004a668f13-kxfauvlnox.chromatic.com/?path=/story/reproduction-property-control-bug--basic
System
Additional context
I'm using Angular with compodoc and I know there are limitations due to the way compodoc works.
Rendering controls for properties does however often break stories due to the defaultValue string compodoc provides.
It's a common use case to assign an imported variable to a property in order to use it in your template.
The only way to work around the new behaviour is to manually exclude or disable all the properties through controls.
In our enterprise monorepo this would result in a huge number of excludes or disabled controls, resulting in a lot of overhead.
.
Relevant Compodoc data
The compodoc data generated for the
myEnumProperty
property and themyEnum
enum used in the reproduction.propertiesClass
enumerations
Expected solution
I would expect the actual values of the variables assigned to the property to render with the correct control.
There might be compodoc limitations blocking this.
As an alternative solution (a global option for) not rendering controls for properties would be acceptable.
The text was updated successfully, but these errors were encountered: