Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Site Editor: Browse styles expand indefinitely when a cover block is in template #57405

Closed
annezazu opened this issue Dec 27, 2023 · 6 comments
Closed
Labels
[Block] Cover Affects the Cover Block - used to display content laid over a background image [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Bug An existing feature does not function as intended

Comments

@annezazu
Copy link
Contributor

Description

If you add a cover block to a template in the Site Editor and open Styles > Browse Styles, the canvas will start to expand indefinitely.

Step-by-step reproduction instructions

  1. Open Appearance > Editor
  2. Open any template and add a cover block.
  3. Open Styles and select "browse styles".
  4. Notice that the canvas starts to expand indefinitely.
  5. Remove cover block.
  6. Open Styles and select "browse styles".
  7. Notice problem goes away.

Screenshots, screen recording, code snippet

Screen.Recording.2023-12-27.at.12.51.51.PM.mov

Environment info

  • WP 6.4.2
  • GB 17.2.3 & GB 17.3

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@annezazu annezazu added [Type] Bug An existing feature does not function as intended [Block] Cover Affects the Cover Block - used to display content laid over a background image [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") labels Dec 27, 2023
@t-hamano t-hamano added the Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json label Dec 28, 2023
@annezazu
Copy link
Contributor Author

Thanks for diving into the prior related issues :D Was going to do that today since I know I've opened a few already.

@ramonjd
Copy link
Member

ramonjd commented Jan 3, 2024

In WordPress 2023 theme it's noticeable on the home template with posts that have featured images.

I hinted at it over in #52297 (comment) - if it's the CSS transition delay that's causing the race condition between height calculation and animation, I'd be open to ditching these transitions completely. E.g.,

diff --git a/packages/block-editor/src/components/iframe/index.js b/packages/block-editor/src/components/iframe/index.js
index 1939f75811..ddada79746 100644
--- a/packages/block-editor/src/components/iframe/index.js
+++ b/packages/block-editor/src/components/iframe/index.js
@@ -264,7 +264,8 @@ function Iframe( {
 						scale !== 1
 							? `scale( ${ scale } )`
 							: props.style?.transform,
-					transition: 'all .3s',
+					//transition: 'all .3s',
+					transition: 'none',
 				} }
 				ref={ useMergeRefs( [ ref, setRef ] ) }
 				tabIndex={ tabIndex }

@annezazu
Copy link
Contributor Author

Ran into this again and 😭 -ed. This would be such a nice quality of life to have fixed.

@ramonjd
Copy link
Member

ramonjd commented Jan 31, 2024

I've tried to find a way to mitigate this again. Here's a brain dump of what I'm seeing.

The issue can be recreated by inserting some containing blocks with vh values set. I'm using the 2023 theme.

To test, I'm previewing the editor via "Browsing styles" in the site editor, which triggers the resizeObserver. Here's some test HTML:

<!-- wp:group {"style":{"dimensions":{"minHeight":"100vh"}},"layout":{"type":"constrained"}} -->
<!-- wp:group {"style":{"dimensions":{"minHeight":"30.8vh"}},"layout":{"type":"constrained"}} -->
<div class="wp-block-group" style="min-height:30.8vh"><!-- wp:image {"id":37,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="http://localhost:8888/wp-content/uploads/2024/01/white-bellied-swallow.jpg" alt="" class="wp-image-37"/></figure>
<!-- /wp:image --></div>
<!-- /wp:group --></div>
<!-- /wp:group -->

From what I can see, the Iframe's useResizeObserver is trying to calculate the height of the window as it's growing.

Element "A", with a vh minHeight value of 30vh for example, will take up 30% of the viewport height. As the window height grows, Element "A" also grows because it wants to get to that 30%.

The transition of all .3s makes it really obvious as it will stretch a little more slowly 😄

The only way I could stop this was to restrict the zoomed out editor's height based on the iframe's surrounding container height.

I also turned off the transition because it's not helpful.

I'm not sure this is the right way though — it's a hack — just posting this in case other folks have ideas.

@t-hamano
Copy link
Contributor

I believe this issue has been fixed in #59334, but if you can reproduce this issue on trunk, feel free to reopen it at any time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Cover Affects the Cover Block - used to display content laid over a background image [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

3 participants