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

Hide the "View" button when previewing a theme #50986

Closed

Conversation

okmttdhr
Copy link
Contributor

@okmttdhr okmttdhr commented May 26, 2023

What?

Hide "View" when previewing a block theme.

Close: #50919

Why?

While we can show a preview on the front of the site with ?theme_preview URL query, I thought we better fix these issues (#50713, #50712) before adding the URL query to the link.
So, I'm proposing to hide it until previewing the front of the site works well.

How?

  • Look at the result of isPreviewing() and show/hide "View"

Testing Instructions

  • Open the Site Editor and add the following to your URL: ?theme_preview=[themePath] where themePath is the relative path to the theme you want to preview (e.g. twentytwentythree).
  • Try to edit it
  • No longer see the "View" button on the header

Screenshots or screencast

When previewing;
590abb864c05501320ba3b5f2249f3b6

When not previewing;
Screen Shot 2023-05-26 at 15 03 17

@okmttdhr okmttdhr marked this pull request as ready for review May 26, 2023 06:38
@okmttdhr okmttdhr changed the title Hide "View" when previewing a theme Hide the "View" button when previewing a theme May 26, 2023
Comment on lines +279 to +284
<PreviewOptions
deviceType={ deviceType }
setDeviceType={ setPreviewDeviceType }
/* translators: button label text should, if possible, be under 16 characters. */
viewLabel={ __( 'View' ) }
>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These preview options work on within the editor, so I think we should leave them as they are useful here.

>
<MenuGroup>
<MenuItem
href={ homeUrl }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think adding the isPreviewingTheme() check here and appending the ?theme_preview URL query would work well to resolve #50712. I think #50713 can be addressed later as a separate PR. The View and Previewing the site links are legitimately useful as is, even if the preview link isn't (yet) appended to all links on the site when previewing.

@draganescu
Copy link
Contributor

I think the first comment by @jeryj is accurate, the mobile and tablet options work well no reason to hide those as well. I think though that hiding the menu group that opens a new tab is good untill we figure out a way to persist theme_preview while browsing the live website.

@scruffian
Copy link
Contributor

untill we figure out a way to persist theme_preview while browsing the live website

I don't see how this could ever be possible

@jeryj
Copy link
Contributor

jeryj commented Jun 6, 2023

Can we check:

  • If we're in a theme preview (GET='theme_preview') and if we're on the frontend of the site? Then append the GET param to all links that match the site url with JS after everything has loaded?

Another way would be to add a filter for all content and block content if the theme preview param is there. Then append the GET param to all links that match the site url?

@scruffian
Copy link
Contributor

I don't see how this could ever be possible

I found a way here: #51412

@okmttdhr
Copy link
Contributor Author

okmttdhr commented Jun 13, 2023

I'm closing this PR since #51412 will come as a solution soon, and the interim solution (this PR) is unnecessary. Thank you for all your reviews.

@okmttdhr okmttdhr closed this Jun 13, 2023
@okmttdhr okmttdhr deleted the update/block-theme-previews-hide-view branch June 13, 2023 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Block Theme Previews: hide "View" when in the Edit View
4 participants