-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
Components which use reflect: true, when using the @property decorator or this.setAttribute result in unexpected behavior.
To reproduce this:
- Create a component that uses this pattern, for example use the following, and then do something like
:host[is-open] {}in the CSS as a response to the attribute being present.
@property({type: Boolean, attribute: 'is-open', reflect: true})
public isOpen: boolean = false;- Have the component manage its own state, for instance it should run
this.isOpen = trueand thenthis.isOpen = falseat some stage in its lifecycle. - When the first
isOpenis called and set totrue, it reflects the attribute into the URL bar to keep Storybook controls in sync. - When the second occurance happens, the attribute remains present in the URL, and does not correctly remove the attribute from the component.
As a result component previews for some interactive elements do not work in Storybook. I've tried ignoring the option with addon-controls by extending argTypes and setting controls to false to no avail. I've also tried adding a JSDoc comment as @private to see if that somehow causes it to ignore that attribute name by removing it from the generated custom elements manifest, but alas, no luck. Seems the only solution for these cases in the meantime is to not use the template method here.
stefanonepanedap
Metadata
Metadata
Assignees
Labels
No labels