Make WordPress Core

Opened 12 years ago

Closed 10 years ago

Last modified 10 years ago

#20233 closed defect (bug) (fixed)

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

Reported by: hd-j's profile hd-J Owned by: azaozz's profile 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 11 years ago.

Download all attachments as: .zip

Change History (12)

#1 @TheAdityaJain
11 years ago

  • Cc mail@… added

#2 @andrewspittle
11 years ago

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

#3 follow-up: @helen
11 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.

11 years ago

#4 in reply to: ↑ 3 @ippetkov
11 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.

#5 @ippetkov
11 years ago

  • Keywords has-patch added; needs-patch removed

#6 @rmarks
11 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.

#7 @andg
11 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.

#8 @westonruter
11 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:

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

#9 @azaozz
10 years 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.

#10 @azaozz
10 years ago

  • Milestone changed from Awaiting Review to 3.9

#11 @Denis-de-Bernardy
10 years 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.