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

Preserve block height during re-render to avoid content jumping #10164

Closed
iandunn opened this issue Sep 25, 2018 · 3 comments
Closed

Preserve block height during re-render to avoid content jumping #10164

iandunn opened this issue Sep 25, 2018 · 3 comments
Labels
General Interface Parts of the UI which don't fall neatly under other labels. [Type] Enhancement A suggestion for improvement.

Comments

@iandunn
Copy link
Member

iandunn commented Sep 25, 2018

Problem

When a user changes some block controls, and the block needs to fetch new data from an API, the block's contents are replaced with a spinner. That changes the block's height, which can cause content jumping.

For example, if you have two tall blocks in a page, and you edit the bottom one, the height of the entire page will be drastically shorter, causing the viewport to jump up to the top of the page. Then, a second later, when the API request returns, the block height will be be restored to its previous height. You'll then have to scroll back down to return to the place you were before, so that you can see the changes and continue editing the block.

https://cloudup.com/cRnMfoye5CF

That capture shows an example of a custom block using SSR, but I was able to reproduce the same behavior with core blocks as well, like Comments.

Possible Solution

I think the block height should be preserved, so that the user isn't interrupted, confused, and forced to scroll to get back to where they originally were.

Gutenberg 3.9.0
Firefox 63

@iandunn iandunn added [Type] Enhancement A suggestion for improvement. General Interface Parts of the UI which don't fall neatly under other labels. labels Sep 25, 2018
@youknowriad
Copy link
Contributor

I'm going to close this issue now. On the framework level, there's no way for Gutenberg to know that there's an async process in progress and preserve the height.

@iandunn
Copy link
Member Author

iandunn commented Jan 16, 2020

At the very least, I think it should be fixed in the Core blocks, because it's a really bad UX.

That could lead to a standardized approach, and the framework could support that, so that it's easy for all blocks to implement.

Here's a rough idea:

import { preserveHeight, restoreNaturalHeight } from '@wordpress/editor';

preserveHeight(); // sets height/max-height equal to current height, overflow: hidden
// make my api calls and update props
restoreNaturalHeight(); // reverses previous operations with a smooth transition

We could come up with a standard solution for the Core blocks, and make it easy for plugins to use it as well.

@youknowriad
Copy link
Contributor

Ok let's reopen for further consideration. I still think it's not worth the complexity and the added API personally.

@youknowriad youknowriad reopened this Jan 17, 2020
@mtias mtias closed this as not planned Won't fix, can't repro, duplicate, stale Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
General Interface Parts of the UI which don't fall neatly under other labels. [Type] Enhancement A suggestion for improvement.
3 participants