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

Block preview - server-side rendered block previews not vertically centered #18134

Closed
mikejolley opened this issue Oct 28, 2019 · 3 comments
Closed
Labels
[Feature] Block API API that allows to express the block paradigm. [Package] Block editor /packages/block-editor [Type] Bug An existing feature does not function as intended

Comments

@mikejolley
Copy link
Contributor

Describe the bug
During implementation of some previews for SSR blocks, I noticed that when the rendered block content is longer than the initial loading state, the vertical alignment (which appears calculated) is not re-calculated. This gives something like this:

Screenshot 2019-10-28 at 13 58 57

You can see the alignment is based on the loading state:

Screenshot 2019-10-28 at 14 02 51

To reproduce
Our code is here woocommerce/woocommerce-blocks#1064

I think it can be replicated with an SSR block which renders long content.

Expected behavior
Once the SSR block is finished rendering, vertical alignment should be re-calculated, and any long content cut off in the preview.

cc @nerrad

@nerrad nerrad added [Package] Block editor /packages/block-editor [Type] Bug An existing feature does not function as intended [Feature] Block API API that allows to express the block paradigm. labels Oct 28, 2019
@nerrad
Copy link
Contributor

nerrad commented Oct 28, 2019

Assuming BlockPreview is used for this (I think it it is?), It appears that triggerRecompute would cause the preview to re-render. I wonder a couple things here:

Could we create a custom <BlockPreviewProvider> context exposing certain elements so that blocks in a preview can discover they are in a preview? Feasibly you could have something like:

  • useIsPreview which returns whether the block is in a preview or not.
  • useTriggerPreviewViewportRecalc (naming is hard, gotta be something better) that basically allows for triggering the re-render of the preview in cases like this where the block content has changed. You could feasibly implement that directly in ServerSideRender to handle this specific bug (but of course that would require either converting ServerSideRender to a functional component or wrapping it in a hoc exposing the trigger.

I did add this to the WP 5.3 must have only because I think since block previews are likely to be utilized extensively once WP 5.3 ships, it's a pretty glaring issue that would be good to address. However, I realize that some of my suggestions for fixing this are probably outside the scope of adding to WP 5.3 at this stage of things (I'm not sure how we can fix otherwise though... unless implementors simply avoid rendering via SSR for previews and simply implement static previews for now?).

@talldan talldan changed the title Block preview - SSR rendered block previews not vertically centered Block preview - server-side rendered block previews not vertically centered Nov 5, 2019
@kathrynwp kathrynwp added the [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. label Aug 3, 2022
@kathrynwp
Copy link

kathrynwp commented Aug 3, 2022

Hi @mikejolley @nerrad @talldan - I've been trying to determine whether if this is still an issue, but so far I haven't been able to replicate. These are the steps I used:

  • Activate WooCommerce
  • Import test product data (All Products > Import > Select sample-products.csv)
  • Open a page
  • Click the block inserter, then click "Browse all"
  • Hover over "Newest products" block

This is what I see:

Add_New_Page_‹Self-hosted_Test—_WordPress

Tested with:

WordPress 6.0.1
Theme: Twenty Twenty-Two
Gutenberg plugin 13.8.0 active or inactive
No other plugins active

If this is no longer an issue, or if there are other steps needed to replicate, please let me know!

@kathrynwp
Copy link

I'm going to go ahead and close this out, but if you are still experiencing the original issue, feel free to add a comment with additional details and I’ll be glad to reopen it.

@kathrynwp kathrynwp closed this as not planned Won't fix, can't repro, duplicate, stale Sep 1, 2022
@kathrynwp kathrynwp removed the [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. label Sep 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block API API that allows to express the block paradigm. [Package] Block editor /packages/block-editor [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

3 participants