Skip to content

Commit

Permalink
Merge pull request #21962 from storybookjs/jpzwarte/fix-viewport-defa…
Browse files Browse the repository at this point in the history
…ult-orientation

Viewport: Fix the `defaultOrientation` config option
  • Loading branch information
ndelangen authored and shilman committed Apr 6, 2023
1 parent 7dc41ea commit d856928
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions code/addons/viewport/src/Tool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ export const ViewportTool: FC = memo(
setState({
selected:
defaultViewport || (viewports[state.selected] ? state.selected : responsiveViewport.id),
isRotated: state.isRotated,
isRotated: defaultOrientation === 'landscape',
});
}, [defaultViewport]);
}, [defaultOrientation, defaultViewport]);

const { selected, isRotated } = state;
const item =
Expand Down
9 changes: 9 additions & 0 deletions code/addons/viewport/template/stories/parameters.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ export const Selected = {
},
};

export const Orientation = {
parameters: {
viewport: {
defaultViewport: Object.keys(MINIMAL_VIEWPORTS)[0],
defaultOrientation: 'landscape',
},
},
};

export const Custom = {
parameters: {
viewport: {
Expand Down

0 comments on commit d856928

Please sign in to comment.