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: Save post before navigating to preview #2193

Merged
merged 3 commits into from
Aug 3, 2017

Conversation

aduth
Copy link
Member

@aduth aduth commented Aug 3, 2017

Related: #1295

This pull request seeks to address the need for a post autosave to occur before showing a preview, as otherwise the preview will not reflect unsaved changes applied to the post.

Implementation notes:

Because popup windows can only be opened in response to user interaction, the solution here is:

  1. Open a popup at about:blank as soon as user clicks button, retaining reference to popup window
  2. Autosave post
  3. When autosave completes, update popup window reference location to saved post link

Testing instructions:

Verify that any unsaved changes are reflected in preview.

  1. Navigate to Gutenberg > New Post
  2. Add a title and/or content
  3. Press Preview button in header
  4. Note a popup window is shown, and after post is saved, you are navigated to a preview reflecting edits from your post

Ensure unit tests pass:

npm test

Caveats:

Published post autosave is not yet implemented. See #1773 (comment).

Can never be disabled, since always has autodraft with post link property

See: #1967
@aduth aduth added the General Interface Parts of the UI which don't fall neatly under other labels. label Aug 3, 2017
@codecov
Copy link

codecov bot commented Aug 3, 2017

Codecov Report

Merging #2193 into master will increase coverage by 0.24%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2193      +/-   ##
==========================================
+ Coverage    22.3%   22.54%   +0.24%     
==========================================
  Files         137      139       +2     
  Lines        4291     4369      +78     
  Branches      722      734      +12     
==========================================
+ Hits          957      985      +28     
- Misses       2815     2858      +43     
- Partials      519      526       +7
Impacted Files Coverage Δ
editor/header/tools/preview-button.js 94.44% <100%> (+94.44%) ⬆️
blocks/library/button/index.js 26.66% <0%> (ø) ⬆️
editor/sidebar/table-of-contents/index.js 0% <0%> (ø) ⬆️
blocks/color-palette/index.js 0% <0%> (ø)
editor/sidebar/table-of-contents/item.js 0% <0%> (ø)
blocks/library/cover-text/index.js 32.43% <0%> (+2.43%) ⬆️
i18n/index.js 88.88% <0%> (+11.11%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a1b1886...16e5352. Read the comment docs.

Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

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

LGTM 👍

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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants