Automattic / wp-calypso

The JavaScript and API powered WordPress.com
https://developer.wordpress.com
GNU General Public License v2.0
12.38k stars 1.98k forks source link

Editor: Broken site previews for custom domains #85374

Open jeyip opened 7 months ago

jeyip commented 7 months ago

Quick summary

When clicking on "preview in new tab" for a new site with a new custom domain, the preview shows a logged out screen.

Screenshot 2023-12-15 at 2 11 17 PM

image

Steps to reproduce

What you expected to happen

I'd see a proper site preview of my post or page

What actually happened

Shown a logged out site preview of a "Coming soon" page

Impact

One

Available workarounds?

Yes, easy to implement

Platform (Simple and/or Atomic)

Simple

Logs or notes

No response

noahtallen commented 7 months ago

Wait for custom domain to activate and set it to the primary domain

this step wasn't strictly necessary for me going through the flow.

noahtallen commented 7 months ago

The current code that is supposed to fix this is here: https://github.com/Automattic/wp-calypso/blob/0b9e2b92dc7af73af5fa73e25e45978326983e9b/apps/editing-toolkit/editing-toolkit-plugin/common/override-preview-button-url.js#L55

However, that selector is currently invalid. (And the next line of code throws an error.) I tried to change the selector, but couldn't get it working.

noahtallen commented 7 months ago

Also, the link in this PR (https://github.com/Automattic/wp-calypso/pull/85179) -- the snackbar "view post" link -- has the same problem where the page is logged out.

noahtallen commented 7 months ago

also this button, which opens the published post in a new tab:

image
noahtallen commented 7 months ago

Ok, I found the root issue of the original bug. The selector has changed to this .components-popover__fallback-container, but that container element doesn't exist until the popover opens for the first time. As a result, there is no container for the mutation observer to observe. That fallback container does exist permanently after the popover is closed, though.

image
maciejpilarski commented 7 months ago

📌 REPRODUCTION RESULTS – Tested on Simple – Replicated / Could Not Replicate / Uncertain

📌 FINDINGS/SCREENSHOTS/VIDEO I was able to reproduce the issue on my test site.

📌 ACTIONS – Triaged