storybook icon indicating copy to clipboard operation
storybook copied to clipboard

Angular: Filter non-inputs from controls

Open shilman opened this issue 2 years ago • 3 comments

Issue: #16865

What I did

Conditionally apply a patch suggested in #16865 which restricts compodoc-inferred argTypes to inputs only.

I implemented this as a feature flag to make it a non-breaking change. I expect this to be the new behavior in v7, but need validation from Angular users/maintainers cc: @storybookjs/angular

In the meantime, setting the following feature flag in .storybook/main.js will get the new behavior:

module.exports = {
  features: {
    angularFilterNonInputControls: true,
  }
};

How to test

See the Example/Button story in example/angular-cli

  • With the flag, it will only show the inputs
  • Without the flag, it will also show the onClick output, populated by a big hairy object

You can also modify the component source to have extra data

lifecycle methods

  ngOnInit() {
  }

members

pharmacies: any[] = [];

methods

@Input()
apiData?: SearchResultsAPIData | null = null;

initializeBasedOnAPIData() {
   this.pharmacies = this.apiData.pharmacies;
}

shilman avatar Aug 05 '22 18:08 shilman

LGTM :heavy_check_mark:

matheo avatar Aug 05 '22 22:08 matheo

This would be an excellent feature to have given the litany of Angular Component-related issues affecting Storybook https://github.com/storybookjs/storybook/issues/17004 https://github.com/storybookjs/storybook/issues/18198 https://github.com/storybookjs/storybook/issues/16865

mrlonis avatar Sep 02 '22 15:09 mrlonis

@shilman @yannbf 🙏🏻 It will be fantastic to merge this; we had to modify inputs in multiple components to be initialized in the constructor as a workaround

alfredoperez avatar Oct 19 '22 21:10 alfredoperez

@shilman Is this not something that should be handled by the docs addon? The ArgTypes is information that is useful for more than just Controls. One example is that filtering the outputs out of the ArgTypes, the auto-generated information used by Actions is lost.

I could be wrong, but I think the need for this within the Angular framework was from issues primarily caused by the defaultValues, which have been getting removed anyway.

Marklb avatar Nov 25 '22 10:11 Marklb

@storybookjs/angular is this good to merge?

ndelangen avatar Jan 13 '23 23:01 ndelangen

@shilman first of all, thanks so much for this, second, sorry for noticing this PR so late, third, can we restructure the features prop to contain framework specific features listed under the framework name and core features on the root level?

i.e.

features: {
     ...coreFeatures,
     angular: {
          filterNonInputControls: true
     }
},

sheriffMoose avatar Feb 21 '23 00:02 sheriffMoose

There is a PR #18549 to control visibility of control groups.

konstantindenerz avatar Mar 29 '23 05:03 konstantindenerz

It looks like the CI failures might have not been related to this specific change. What would need to happen to move this PR forward? I'm willing to put in some time, as this is a crucial change to make ArgsTable and Controls useful for Angular components.

b12f avatar Apr 24 '23 14:04 b12f

I've been following this as I can't update Storybook due to it having problems with Angular. Could @cdedreuille or someone else please provide a reason for why this was closed? If this was fixed by other code, could a reference please be provided in case it isn't working as expected?

Fydon avatar Apr 25 '23 12:04 Fydon

Can I do something to get this working? altho I liked the other PR more where you can configure what groups you want to show (or hide) https://github.com/storybookjs/storybook/pull/18549

gvlekke avatar Aug 15 '23 08:08 gvlekke

@valentinpalkovic Is this PR still something we plan to bring to a merge?

ndelangen avatar Nov 28 '23 08:11 ndelangen

Definitely! Maybe between Christmas and New Year, I will find some time to reevaluate this (the PR is pretty old)

valentinpalkovic avatar Nov 28 '23 08:11 valentinpalkovic

Definitely! Maybe between Christmas and New Year, I will find some time to reevaluate this (the PR is pretty old)

If you want some help please let me know.

gvlekke avatar Nov 29 '23 14:11 gvlekke