Skip to content

Commit

Permalink
Editor Canvas: Fix animation when device type changes (#56970)
Browse files Browse the repository at this point in the history
* Editor Canvas: Fix animation when device type changes

* Include margin in deviceStyles
  • Loading branch information
t-hamano authored Dec 13, 2023
1 parent 2936660 commit e07802b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# useResizeCanvas

This React hook generates inline CSS suitable for resizing a container to fit a device's dimensions. It adjusts the CSS according to the current device dimensions. It has no effect on desktop.
This React hook generates inline CSS suitable for resizing a container to fit a device's dimensions. It adjusts the CSS according to the current device dimensions.

On-page CSS media queries are also updated to match the width of the device.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ export default function useResizeCanvas( deviceType ) {
overflowY: 'auto',
};
default:
return null;
return {
marginLeft: marginHorizontal,
marginRight: marginHorizontal,
};
}
};

Expand Down
5 changes: 4 additions & 1 deletion packages/editor/src/components/editor-canvas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,10 @@ function EditorCanvas(
height="100%"
iframeProps={ {
...iframeProps,
style: { ...iframeProps?.style, ...deviceStyles },
style: {
...iframeProps?.style,
...deviceStyles,
},
} }
>
{ themeSupportsLayout &&
Expand Down

1 comment on commit e07802b

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in e07802b.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7190092835
📝 Reported issues:

Please sign in to comment.