question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Knobs-addon: Angular Components lose interactivity after adjusting property via knob

See original GitHub issue

Describe the bug When adjusting properties on an Angular component via a Knob, the Angular component interactions start having issues.

To Reproduce Steps to reproduce the behavior:

  1. Configure a story using the code snippet below
  2. Change a property using the knob add-on (change the first label to “error”)
  3. Click the Second Tab in the preview pane
  4. Notice the tab content does not change
  5. Click the tab content
  6. Notice the tab switches

The example leverages @angular/material, but I came across this via proprietary components as well.

Expected behavior Component should continue to work as expected after changing property via knob.

Code snippets


storiesOf('Tabs', module)
  .addDecorator(
    moduleMetadata({
      imports: [
        BrowserAnimationsModule,
        MatTabsModule,
        MatIconModule,
      ],
    }),
  )
  .add(
    'with knobs',
    () => ({
      template: `
      <mat-tab-group>
        <mat-tab *ngFor="let item of items">
          <ng-container *matTabLabel>
            <mat-icon>{{ item.icon }}</mat-icon>
            <span>{{ item.label }}</span>
          </ng-container>
          <ng-container *matTabContent>
            Content
          </ng-container>
        </mat-tab>
      </mat-tab-group>
    `,
      props: {
        items: object('items', [
          {
            label: 'first',
            icon: 'home',
          },
          {
            label: 'second',
            icon: 'face',
          },
          {
            label: 'third',
            icon: 'group_work',
          },
          {
            label: 'fourth',
            icon: 'grade',
          },
          {
            label: 'fifth',
            icon: 'feedback',
          },
        ], 'TABS-GROUP'),
      }
    }),
    { notes: 'My notes' }
  );

System:

  • OS: Windows 10
  • Browser: Chrome
  • Framework: Angular
  • Addons: @storybook/addon-knobs
  • Version: 5.1.9

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:10
  • Comments:22 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
mgameovercommented, Apr 14, 2020

Just checked that with the official sample (storybook/examples/angular-cli v6.0.0-alpha.33). The same thing, it stops working after changing visibility using *ngIf.

But it works with v5.0.11 So, I believe @andrei-ilyukovich is right about the root cause - comment.

2reactions
literalpiecommented, Oct 31, 2019

I’m still seeing this issue in 5.2.5.

tried with 5.3.0-alpha.34, but the knob wasn’t showing up at all! I think that’s a different issue though…

edit: I’m only seeing this issue when using addon-docs. That might change things

Read more comments on GitHub >

github_iconTop Results From Across the Web

Component interaction - Angular
This cookbook contains recipes for common component communication scenarios in which two or more components share information.
Read more >
Angular 2 - View not updating after model changes
I can see from my log statements and the network traffic that the JSON data being returned is changing, and my model is...
Read more >
Angular & Storybook. Building & Documenting UI Components
We are going to look now into the process step by step, from creating a component, using Storybook to work on it and...
Read more >
Angular Development #10 - RouteReuseStrategy - Intertech
Overview. Angular provides a powerful built in router to emulate traditional web page navigation and display new components when accessing ...
Read more >
How to Write Better Components in Angular - Bits and Pieces
Pouring the above into a single html file is not ideal, as the app grows we will have too many codes in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found