-
-
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
Storybook 6.2.0-beta new angular renderer ovverides properties #14147
Comments
Yes, it's true. But I don't think it's a "bug". 🙈 (but a change in behaviour that I would also like to make). Give me a few days to find time to make a complete answer. (very busy lately 😞 ) |
Well I don’t think storybook should change in any way properties that are
not inputs and are even private (i know ts private is come and take It).
But, sure will wiat for update on Your side. For now will keep legacy
rendering on.
W dniu śr., 10.03.2021 o 08:48 ThibaudAV ***@***.***>
napisał(a):
… Yes, it's true. But I don't think it's a "bug". 🙈 Give me a few days to
find time to make a complete answer. (very busy lately 😞 )
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#14147 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFKBQQJZ3Y24YTJABFG6NVDTC4P5DANCNFSM4YVC2VIQ>
.
|
In fact I don't know where to start... many things are mixed up Problem Replication:If I understand correctly your example is this: Click to expand!import { Story, Meta, moduleMetadata } from '@storybook/angular';
import { Input, Component } from '@angular/core';
@Component({ selector: 'foo', template: 'notInputProperty : {{notInputProperty }}' })
class SampleComp {
@Input() input1: string;
notInputProperty = 'rr';
ngOnChanges() {
this.notInputProperty = 'kokos';
}
}
export default {
title: 'Legacy / angularLegacyRendering',
component: SampleComp,
decorators: [
moduleMetadata({
declarations: [SampleComp],
}),
],
} as Meta;
const Template: Story<SampleComp> = (args) => {
console.log(args);
return {
props: args,
// angularLegacyRendering: true,
};
};
export const Sample = Template.bind({});
Sample.args = {}; here are the steps I do :
Now, if i do same step (close storybook client and restart it) but i start storybook with
I think the problem comes from compodoc. Which discovers all properties of your component class and adds them to agrs. Discussions are already in progress to replace compodoc personally I don't like compodoc at all and I don't use it I recommend you not to trust compodoc if you use it and to do something like : const Template: Story<SampleComp> = (args) => ({
props: {
input1: args.input1
},
}); to be sure to send only the expected "arg" So :
Wait for an alternative. or manually add controls of args
Several topics are talking about it, it also blocks some features or else #12438 I really wish I could ban it or split it into 2 like: but this is a big breaking changes I think and we have to wait for a major version (I was told) 😁 fun fact :
not with controls with compodoc. As you do not completely reload the storybook client compodoc does not reanalyze your component legacy rendering and ngOnChangesI don't recommend to use legacy rendering if you have stories and component with ngOnchanges. it is manually called by the renderer and is not exactly the same as native angular.
The new renderer doesn't work the same way because it simulates a template for your component and therefore lets the native angular mechanism do the work |
A possible fix until the main issue gets fixed you can disable // Because of the following issues we cannot use Compodoc to automatically find component inputs:
// https://github.com/storybookjs/storybook/issues/14147
// https://github.com/storybookjs/storybook/issues/11613
// It seems storybook will try to add support for detecting inputs because compodoc is not maintained anymore and they end up overriding angular component
// props which are not imputs with ng versions bigger than 8.0
// When this is closed we can probably see what's the upgrade path: https://github.com/storybookjs/storybook/issues/8672
// import { setCompodocJson } from "@storybook/addon-docs/angular";
import { INITIAL_VIEWPORTS } from '@storybook/addon-viewport';
// import docJson from "../documentation.json";
// setCompodocJson(docJson);
export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
viewport: {
viewports: INITIAL_VIEWPORTS,
},
} |
We turned on legacyRendering because we got these kinds of errors:
How would we turn off angularLegacyRendering and solving the above error? |
@salmin89 can you give more details about the component you added in the story ? Make sure that you do not directly pass all
|
I think we can close it a workaround has been added to avoid the override |
Hi, the problem still persists and the workaround also doesn't work anymore. Storybook: v6.50-alpha.14 |
In case it helps anyone else who ends up here I added {
...
"projects": {
"my-lib": {
...
"architect": {
"storybook": {
"builder": "@storybook/angular:start-storybook",
"options": {
...
"compodocArgs": ["-e", "json", "--disablePrivate", "--disableInternal", "--disableLifeCycleHooks"]
}
}, Another workaround that I don't like as much is to set the parameters on my story to either exclude or include the properties from the controls. Primary.parameters = {
controls: {
// either exclude or include
exclude: ['ngAfterContentInit', 'display'],
include: ['percentage', 'error', 'status']
},
} |
Describe the bug
if component has some properties that are not inputs they are overridden
and template will be
then notInputProperty will be overridden after change detection we will get rendered ```notInputProperty : `.
if we add
@Input
decorator to this property then it works as it should and we get rendered: ```notInputProperty : kokos'.setting
angularLegacyRendering: true,
solves the issue.fun fact:
after first time storybooks renders You will change the name of property to lets say
notInputProperty2
then it will work!So maybe it has something to do with controls?
Restarting storybook (ctr+c) and npm run storybook again will again cause it to be overridden till You again change the name of property to lets say
notInputProperty3
.System
The text was updated successfully, but these errors were encountered: