Skip to content

[addon/viewport] defaultViewport is not applied #15923

@theKashey

Description

@theKashey

Describe the bug
Same as #1548 - defaultViewport is not applied

To Reproduce

  • Create two stories
  • configure defaultViewport for one story
  • Sometimes (rarely) defaultViewport will be applied, but usually not.

System

    @storybook/addon-essentials: ^6.3.1 => 6.3.1 
    @storybook/addons: ^6.1.21 => 6.3.2 
    @storybook/react: ^6.3.1 => 6.3.1

Additional context
It's literally "not applied", something with useAddonState
https://github.com/storybookjs/storybook/blob/next/addons/viewport/src/Tool.tsx#L152-L160

   useEffect(() => {
      setState({  
        selected:  //                         <-- called here
          defaultViewport || (viewports[state.selected] ? state.selected : responsiveViewport.id),
        isRotated: state.isRotated,
      });
    }, [defaultViewport]);

    const { selected, isRotated } = state; // <--- not updated here

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions