storybookjs / storybook

Storybook is the industry standard workshop for building, documenting, and testing UI components in isolation
https://storybook.js.org
MIT License
84.09k stars 9.25k forks source link

ViewDestroyedError when switching between ngx-datatable stories and not working knobs #10128

Closed aleohli closed 4 years ago

aleohli commented 4 years ago

When switching between stories for the component that uses ngx-datatable component ViewDestroyedError appears. It appears only in the situation when switching between stories with changed table structure.

Simple example below:

Component that uses ng-datatable component: `import { Component, Input } from '@angular/core';

@Component({ selector: 'data-table', template: <ngx-datatable class="material expandable" rowHeight="auto" headerHeight="auto" footerHeight="40" columnMode="force" [rows]="rows"> <ngx-datatable-column *ngIf = "multiSelection" [headerCheckboxable]="true" [checkboxable]="true"> </ngx-datatable-column> <ngx-datatable-column *ngFor="let column of columns" [prop]="column" [name]="column"> </ngx-datatable-column> </ngx-datatable> , }) export class TableComponent { @Input() multiSelection: boolean; @Input() rows = []; columns = ['firstName', 'lastName']; }`

And stories file: `const firstRowsVariant = [ {firstName: 'John', lastName: 'Smith'}, {firstName: 'Donald', lastName: 'Trump'}, {firstName: 'Barack', lastName: 'Obama'}, ];

const secondRowsVariant = [ {firstName: 'Donald', lastName: 'Trump'}, {firstName: 'Barack', lastName: 'Obama'}, ];

storiesOf('Components|Test', module).addDecorator( moduleMetadata({ imports: [TableModule] }) ).add( 'Multiselection enabled ver1', () => ({ component: TableComponent, props: { multiSelection: true, rows: firstRowsVariant } }), { notes: '' } ).add( 'Multiselection enabled ver2', () => ({ component: TableComponent, props: { multiSelection: true, rows: secondRowsVariant } }), { notes: '' } ).add( 'Multiselection disabled', () => ({ component: TableComponent, props: { multiSelection: false, rows: firstRowsVariant } }), { notes: '' } );`

Behaviour:

Error: image

stale[bot] commented 4 years ago

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!

stale[bot] commented 4 years ago

Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook!