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 Assembler - Patterns with maps don't render sometimes because the domReady is undefined #76936

Closed
miksansegundo opened this issue May 15, 2023 · 8 comments
Assignees
Labels
[Feature] Block Patterns Pattern content itself, and the functionality that lets you create patterns. [Pri] Normal [Type] Bug

Comments

@miksansegundo
Copy link
Contributor

What

Sometimes patterns with the block wp:jetpack/map don't render the map.

MAP ✅ MAP ❌
Image Image
Image Image
Image Image
Image Image

Why

Maybe the cause is that domReady is undefined.

How

  • Explore the patterns in the category Contact, you should see four patterns with maps
  • Find a fix for the domReady issue if that is the cause
  • Check if it might be something related to the map style, because when the style is terrain the map uses Mapbox otherwise uses Apple maps. It doesn't seem related because both types are not rendered randomly.
    Image
    Image
@miksansegundo
Copy link
Contributor Author

@arthur791004 where is the code that uses domReady?

@miksansegundo miksansegundo added [Type] Bug [Feature] Block Patterns Pattern content itself, and the functionality that lets you create patterns. labels May 15, 2023
@arthur791004
Copy link
Contributor

Here. On production, it will try to get the value from window.wp.domReady

@miksansegundo
Copy link
Contributor Author

I debugged it and found that the issue happens because the script wp-dom-ready is sometimes missing in the response of get_rendered_patterns.

WITH WITHOUT
Screenshot 2566-05-22 at 23 53 25 Screenshot 2566-05-22 at 23 53 09

You can debug them using the pattern IDs with maps 10413, 5634, 280, 1397. I still don't know the root cause. Maybe you have ideas?

@miksansegundo
Copy link
Contributor Author

Maybe there is an issue related to the dependency between wp-dom-ready and wp-polyfill that is injected via webpack. See dependency-extraction-webpack-plugin.

I found issues that explain about the polyfill dependency and how the map assets load in the editor:

@miksansegundo
Copy link
Contributor Author

@Automattic/lego 🚨 It seems this issue is randomly affecting all patterns with Jetpack blocks.

I'm seeing this same issue in other patterns with the Jetpack blocks like jetpack/subscriptions and jetpack/recurring-payments.

You can reproduce it in the assembler by scrolling the list of patterns in the category Shop with the JS console open.

Screenshot 2566-05-23 at 14 11 16 Screenshot 2566-05-23 at 14 11 30

@miksansegundo
Copy link
Contributor Author

I think it is random because the request /block-renderer/patterns/render receives multiple patterns and only the first pattern that requires wp-dom-ready will get it.

Maybe we have to requeue the assets for each pattern before running apply_filters( 'the_content', $pattern->html ).

See get_rendered_patterns fbhepr%2Skers%2Sjcpbz%2Sjc%2Qpbagrag%2Serfg%2Qncv%2Qcyhtvaf%2Sraqcbvagf%2Soybpx%2Qeraqrere%2Soybpx%2Qeraqrere%2Qcnggreaf.cuc%3Se%3Qo2n4r08s%2386-og

@miksansegundo
Copy link
Contributor Author

🐛 Found it!! See D111593-code

@arthur791004
Copy link
Contributor

Closing it as it's completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block Patterns Pattern content itself, and the functionality that lets you create patterns. [Pri] Normal [Type] Bug
Projects
None yet
Development

No branches or pull requests

3 participants