storybookjs / storybook

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

Knobs from other stories appearing on inappropriate stories #10590

Closed IntusFacultas closed 4 years ago

IntusFacultas commented 4 years ago

Description:

When using the Knobs addon, knobs from other stories occasionally appear in inappropriate stories until you click "Reset" at which point they disappear.

Reference: #1869

Reproduction:

In my case, a very specific set of knobs are the ones that reappear. Specifically: Steps to reproduce the behavior:

  1. Create a story for some component and add the following Props
    const propData = {
    transitions: {
    default: object("Transitions", [
      {
        transitionId: 1,
        originState: {
          stateId: 1,
          stateName: "Start",
          stateDescription: "Start state",
          stateType: "START"
        },
        destinationState: {
          stateId: 2,
          stateName: "Task 1",
          stateDescription: "Do something",
          stateType: "TASK"
        }
      },
      {
        transitionId: 2,
        originState: {
          stateId: 1,
          stateName: "Start",
          stateDescription: "Start state",
          stateType: "START"
        },
        destinationState: {
          stateId: 3,
          stateName: "Task Cancelled",
          stateDescription: "Don't do something",
          stateType: "CANCEL"
        }
      },
      {
        transitionId: 3,
        originState: {
          stateId: 1,
          stateName: "Start",
          stateDescription: "Start state",
          stateType: "START"
        },
        destinationState: {
          stateId: 4,
          stateName: "Rework",
          stateDescription: "Do something again",
          stateType: "REWORK"
        }
      },
      {
        transitionId: 4,
        originState: {
          stateId: 1,
          stateName: "Start",
          stateDescription: "Start state",
          stateType: "START"
        },
        destinationState: {
          stateId: 5,
          stateName: "Complete Task",
          stateDescription: "Done something",
          stateType: "COMPLETE"
        }
      }
    ])
    },
    instanceId: {
    default: text("Instance ID", instanceID)
    },
    workflowUrl: {
    default: text("Workflow URL", baseURL)
    },
    workflowId: {
    default: text("Workflow ID", workflowID)
    },
    textFlavor: {
    default: text("Flavor", "")
    }
    };
  2. Define another story with different props
  3. Run storybook and view the second story
  4. See error

Expected Behavior: The appropriate knobs should appear without the additional knobs showing up.

Screenshots Here is the bug appearing: image

Here is after pressing reset on the same story: image

Code snippets This is the source code for the above story:

export const Alert = () => ({
  components: { VueStaticAlert },
  props: {
    flavor: {
      default: text("Flavor", ""),
    },
    animated: {
      default: boolean("Animated", false),
    },
    closeable: {
      default: boolean("Closeable", false),
    },
  },
  template: `
        <div>
          <vue-static-alert :flavor="flavor" :animated="animated" :closeable="closeable"><span>Test</span></vue-static-alert>
          <hr>
          Available Flavors:
          <ul>
            <li>success</li>
            <li>warning</li>
            <li>info</li>
            <li>danger</li>
          </ul>
        </div>
    `,
});

System:

Environment Info:

  System:
    OS: Windows 10 10.0.18362
    CPU: (8) x64 Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz    
  Binaries:
    Node: 12.14.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.4 - ~\Documents\Work\Storybook\node_modules\.bin\yarn.CMD
    npm: 6.13.7 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: 44.18362.449.0
  npmPackages:
    @storybook/addon-a11y: ^5.3.18 => 5.3.18 
    @storybook/addon-actions: ^5.3.18 => 5.3.18 
    @storybook/addon-console: ^1.2.1 => 1.2.1 
    @storybook/addon-knobs: ^5.3.18 => 5.3.18 
    @storybook/addon-notes: ^5.3.18 => 5.3.18 
    @storybook/addon-storysource: ^5.3.18 => 5.3.18 
    @storybook/addon-viewport: ^5.3.18 => 5.3.18 
    @storybook/vue: ^5.3.18 => 5.3.18 
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!

IntusFacultas commented 4 years ago

Hi just bumping this since its still an issue.

shilman commented 4 years ago

Hi gang, We’ve just released addon-controls in 6.0-beta!

Controls are portable, auto-generated knobs that are intended to replace addon-knobs long term.

Please upgrade and try them out today. Thanks for your help and support getting this stable for release!

shilman commented 4 years ago

For anybody who is interested in Controls but don't know where to start, I've created a quick & dirty step-by-step walkthrough to go from a fresh CRA project to a working demo. Check it out:

=> Storybook Controls w/ CRA & TypeScript

There are also some "knobs to controls" migration docs in the Controls README:

=> How do I migrate from addon-knobs?

IntusFacultas commented 4 years ago

Thank you! I'll integrate this ASAP.

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!

madebycaliper commented 4 years ago

@IntusFacultas I'm having the same exact issue. While the upcoming release of args in v6.x is cool, I'm using 5.3 and would like this to work without updating. What can I do?

YaronMiro commented 2 years ago

I also encountered this bug when knobs are not cleared between stories, if using the @storybook/react up to version 6.3.13 it works as expected but higher versions are not. At least there is a possibility to upgrade from version 5 to 6 but not the latest version 6.x if intending to use knobs.