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

Preview button does not redirect if pressed while unsaved changes exist #7154

Closed
aduth opened this issue Jun 5, 2018 · 2 comments
Closed
Labels
General Interface Parts of the UI which don't fall neatly under other labels. [Type] Bug An existing feature does not function as intended

Comments

@aduth
Copy link
Member

aduth commented Jun 5, 2018

Related: #7124
Separate from publish preview task (#4099)

If the user hits the Preview button for a draft where unsaved changes exist, the preview window appears but the user is never redirected to the post.

Steps to reproduce:

  1. Navigate to Posts > Add New
  2. Enter a title
  3. Hit Preview button (before autosave occurs)

Expected result:

Intermediary page appears, but eventually redirects to preview.

Actual result:

Redirect never occurs.

Workaround:

If the user first hits Save before Preview, then the preview loads correctly.

Suspected cause:

The logic for detecting whether a redirect should take place depends on the post's modified field being updated. This does not occur for autosaves. A preview is expected to be saved as an autosave (at least for published posts, which are not expected to be updated immediately).

const hasFinishedSaving = (
isAwaitingSave &&
modified !== this.props.modified
);
if ( hasFinishedSaving && this.previewWindow ) {
this.previewWindow.location = link;
this.setState( { isAwaitingSave: false } );
}

@aduth aduth added [Type] Bug An existing feature does not function as intended General Interface Parts of the UI which don't fall neatly under other labels. labels Jun 5, 2018
@jenny-leung
Copy link

jenny-leung commented Jun 12, 2018

I have the same issue with Firefox and Chrome. Both do not load preview if not saved.
Difference:
Chrome opens a new tab with "about:blank" with no console log error.
Firefox shows the same url as the post edit page instead of the preview url with the following console log error every time I click preview without saving draft
TypeError: this.previewWindow is undefined[Learn More] index.js:12:150551
If I do not save draft and open the preview link from browser history instead of clicking the preview button, the preview renders correctly. However, every time I click preview, it changes the url. It doesn't keep the working url and refresh.

@aduth
Copy link
Member Author

aduth commented Jun 25, 2018

Should be fixed in #7130

@aduth aduth closed this as completed Jun 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
General Interface Parts of the UI which don't fall neatly under other labels. [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

2 participants