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

Disregard template validity in the context of FSE #35041

Merged
merged 1 commit into from
Aug 1, 2019

Conversation

noahtallen
Copy link
Member

@noahtallen noahtallen commented Aug 1, 2019

This is VERY much a hack around WordPress/gutenberg#11681

Previously, it worked to just hack this once at the beginning. But the error message is also popping up when performing undo in Gutenberg. I admit it's possible that something different could be happening in this case. But I haven't been able to come up with a reason why - my best guess is that it also triggers the same template validity issues that we had to hack when the editor loads. I realize this is not a great patch, so I'm open to other suggestions. Note that we won't be able to ditch this check entirely because of the core gutenberg issue.

The downsides of this approach: we never get warned if the template is invalid for good reasons. However, I've tried to get something to break in the editor after the template validity goes wrong after performing undo, but everything works as expected. So I don't really think that anything is going wrong under the hood.

Changes proposed in this Pull Request

  • Always disregard template validity in the context of FSE.

Testing instructions

  1. Pull this code and run it in your local FSE setup
  2. Open a page with FSE enabled.
  3. Make an edit to a block inside the post content area.
  4. Click undo in the top toolbar. Previously, the template validity notice would pop up per FSE: Performing undo causes the "content of your post doesn’t match" message #34831. You should no longer see any notice when clicking undo.

Fixes #34831
cc @mmtr who originally authored this hack to only happen once.

This is VERY much a hack around
WordPress/gutenberg#11681

Previously, it was fine to do this just once at the beginning. But we
discovered that it also happens when performing undo.
Granted, performing undo might do something else, but my best guess is
that it's related to the above issue.
@noahtallen noahtallen added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. [Goal] Full Site Editing labels Aug 1, 2019
@noahtallen noahtallen requested review from mattwiebe, mmtr and a team August 1, 2019 01:01
@noahtallen noahtallen requested a review from a team as a code owner August 1, 2019 01:01
@matticbot
Copy link
Contributor

@noahtallen noahtallen self-assigned this Aug 1, 2019
@@ -19,7 +19,5 @@ const unsubscribe = subscribe( () => {
}
if ( select( 'core/editor' ).isValidTemplate() === false ) {
dispatch( 'core/editor' ).setTemplateValidity( true );
// should only need to do this once
Copy link
Member Author

Choose a reason for hiding this comment

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

RIP :)

@matticbot
Copy link
Contributor

This PR does not affect the size of JS and CSS bundles shipped to the user's browser.

Generated by performance advisor bot at iscalypsofastyet.com.

@apeatling
Copy link
Member

apeatling commented Aug 1, 2019

Confirmed this fixes the notice when performing an undo. Could we use this hack for now and contribute a better fix back to core Gutenberg via that issue?

@vindl
Copy link
Member

vindl commented Aug 1, 2019

The downsides of this approach: we never get warned if the template is invalid for good reasons. However, I've tried to get something to break in the editor after the template validity goes wrong after performing undo, but everything works as expected. So I don't really think that anything is going wrong under the hood.

I think this is fine since the Fix action that is shown to user in this case isn't correcting it. If they can't fix it, there isn't much value in showing the notice when there are no other noticeable defects.

Copy link
Member

@vindl vindl left a comment

Choose a reason for hiding this comment

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

Works as described! :shipit:

I don't have better ideas atm, except for fixing it in core.

@vindl vindl added [Status] Ready to Merge and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Aug 1, 2019
@noahtallen
Copy link
Member Author

noahtallen commented Aug 1, 2019

If they can't fix it, there isn't much value in showing the notice

That's a great point. Definitely improves the UX since the notice would really only be helpful to us if it was telling the truth.

@noahtallen noahtallen merged commit 29dfce4 into master Aug 1, 2019
@noahtallen noahtallen deleted the fix/disregard-template-validity branch August 1, 2019 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FSE: Performing undo causes the "content of your post doesn’t match" message
4 participants