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

Post Excerpt: Fix previews #37648

Merged
merged 1 commit into from
Dec 29, 2021
Merged

Post Excerpt: Fix previews #37648

merged 1 commit into from
Dec 29, 2021

Conversation

Mamaduka
Copy link
Member

Description

Follow-up for #37622.

The preview filter applies content from autosave to the queries object (and global post). When we pass a post ID to the get_the_content, it uses an instance of the post where those changes aren't applied. Using null instead of $post_id in this scenario fixes the issue.

The same applies to the get_the_excerpt. PR removes the post ID argument to fix previews.

How has this been tested?

Using TT2 theme.

  1. Update the "Single" template to use Post Excerpt.
  2. Makes a change to a post without saving.
  3. Click Preview -> Preview in new tab
  4. Confirm that changes are reflected in the preview.

Types of changes

Bugfix

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR (please manually search all *.native.js files for terms that need renaming or removal).

@Mamaduka Mamaduka self-assigned this Dec 29, 2021
@Mamaduka Mamaduka added [Block] Post Excerpt Affects the Post Excerpt Block [Type] Bug An existing feature does not function as intended Backport to WP 6.6 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta labels Dec 29, 2021
Copy link
Contributor

@ntsekouras ntsekouras left a comment

Choose a reason for hiding this comment

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

LGTM, thanks George!

I'm wondering though if this and the previous PR for post content/title, can create the impression to the user that the changes they see are saved, which they are not, and never push that Update button 😄

The difference between all the other previews is that they live in the editor and any pending unsaved changes are indicated by the status of the Update button.

In preview in new tab case could a notification that unsaved changes exist work better and not include these changes as before?
Or should we add such a complementary notification with the new functionality that states that the preview contains unsaved changes? 🤔

@Mamaduka
Copy link
Member Author

Thanks for testing, Nik.

I'm wondering though if this and the previous PR for post content/title, can create the impression to the user that the changes they see are saved, which they are not, and never push that Update button 😄

It is hard to say without user testing, but I doubt it. The preview functionality is almost the same as in the classic editor.

Previewing posts will create an autosave so user can always restore their changes. Plus, they will be prompted with a confirmation modal when leaving the page.

Let's keep the fix simple for 5.9. We can always better highlight unsaved changes in previews in the future if needed.

Confirmation

CleanShot 2021-12-29 at 12 11 21

@Mamaduka Mamaduka merged commit a5cb5b6 into trunk Dec 29, 2021
@Mamaduka Mamaduka deleted the fix/post-excerpt-previews branch December 29, 2021 09:32
@github-actions github-actions bot added this to the Gutenberg 12.4 milestone Dec 29, 2021
@noisysocks noisysocks removed the Backport to WP 6.6 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Jan 4, 2022
noisysocks pushed a commit that referenced this pull request Jan 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Post Excerpt Affects the Post Excerpt Block [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants