Make WordPress Core

Opened 4 years ago

Closed 20 months ago

Last modified 20 months ago

#20233 closed defect (bug) (fixed)

Preview opens in the same window when edit panel was previously another Preview window

Reported by: hd-J Owned by: azaozz
Milestone: 3.9 Priority: normal
Severity: normal Version: 3.3.1
Component: Editor Keywords: easy-fix has-patch
Focuses: Cc:


Steps to reproduce:

  1. Create a new post, save as draft
  2. Click "Preview"
  3. Go to the Preview window, and from there use the Admin bar to go back to the Dashboard and start writing a new post
  4. Save that new post as draft
  5. Hit "Preview"
    • Expected result: preview opens in a new window
    • Result: preview opens in the same window

Is there some way we could get around that? For people working with multiple tabs, it can be really confusing.

Attachments (1)

20233.diff (1.8 KB) - added by ippetkov 2 years ago.

Download all attachments as: .zip

Change History (12)

comment:1 @TheAdityaJain3 years ago

  • Cc mail@… added

comment:2 @andrewspittle2 years ago

Tested and confirmed in 3.5.2 and in trunk. Still reproducible.

comment:3 follow-up: @helen2 years ago

  • Keywords easy-fix added

I think it's probably as simple as changing the target from "wp-preview" to "_blank", if this is indeed a desired change.

@ippetkov2 years ago

comment:4 in reply to: ↑ 3 @ippetkov2 years ago

Replying to helen:

I think it's probably as simple as changing the target from "wp-preview" to "_blank", if this is indeed a desired change.

Adding "_blank" to the target would make a new tab appear for every time "preview" is clicked.

I've added a patch which basically uses the post ID as part of the target name. Thus every post gets its own dedicated preview tab which will get refreshed on subsequent previews.

Also, entering the post editor will clear the tab's frame name. This is so that if a user starts editing post 1 and then begins editing post 2 from post 1's preview page, a new preview page gets opened for post 1 instead of blowing away their editing in progress.

comment:5 @ippetkov2 years ago

  • Keywords has-patch added; needs-patch removed

comment:6 @rmarks2 years ago

In Chrome 28.0.1500.72 m, I was unable to reproduce. Instead, I got the Expected Result (preview opens in a new window).

Looking at this from a different perspective, I'm thinking there should be a different scenario. If I was to repeat the cycle of Save Draft, Preview, Edit Post 5 times, I've have 6 tabs open (5 on edit and 1 on preview) for this post. I'm unsure if it's possible, but I feel the Edit Post link in the Admin Bar should make the original Edit Post tab be in focus.

comment:7 @andg2 years ago

The proposed patch works for me; in the end it's up to the user if this leads to opening lots of tabs.

comment:8 @westonruter2 years ago

  • Cc weston@… added

I wasn't aware of this ticket and addressed the problem in the Customizer Everywhere plugin. It seems I came up with the exact same solution by including the current post ID in the window target name. Here's the relevant part of the plugin: https://github.com/x-team/wp-customizer-everywhere/blob/454c6debcc1ac0f34caeda3f217542b1d1cb3b21/edit-post.js#L29-L77

I also alerted @azaozz in ticket:25272#comment:7 to preserve the change in the preview window target in his work to refactor autosave.

comment:9 @azaozz20 months ago

  • Owner set to azaozz
  • Resolution set to fixed
  • Status changed from new to closed

In 27079:

Open previews of different posts in different windows/tabs. Prevent confusion when using a former preview window again if the user navigated to edit another post. If the first post is still being edited, clicking Preview there will use the current window to show the preview. Props ippetkov, fixes #20233.

comment:10 @azaozz20 months ago

  • Milestone changed from Awaiting Review to 3.9

comment:11 @Denis-de-Bernardy20 months ago

azaozz - Curious to know… This opens a new tab when the preview button is hit — which is fine.

But then, leave the tab open, and return to the post that is being edited. Edit a bit more, and hit preview again. Nothing seems to happen. It should probably focus the preview window in addition to opening it, auto-close the preview tab when editing resumes, or always open a new preview tab.

Note: See TracTickets for help on using tickets.