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

Gutenberg: Investigate improvements when Block Is Invalidated #37230

Closed
gwwar opened this issue Oct 31, 2019 · 3 comments
Closed

Gutenberg: Investigate improvements when Block Is Invalidated #37230

gwwar opened this issue Oct 31, 2019 · 3 comments
Labels
[Goal] Gutenberg Working towards full integration with Gutenberg [Type] Enhancement

Comments

@gwwar
Copy link
Contributor

gwwar commented Oct 31, 2019

Please take a few days to investigate what next steps make sense. We can create new issues/refine the summary here to reflect what we find.

Suggested courses of action:

  • Promote Attempt Block Recovery as primary CTA or auto-run the Attempt Block Recovery (handled by Gutenberg: Change primary action to Attempt Block Recovery #38329 )
  • Investigate if server transforms can fix issues earlier on
  • See if core contributions are possible to make block validation both more relaxed and bulletproof (additive attributes/whitespace differences for example should be okay)

Context

When a block parses HTML markup, it also tries to validate the data by re-serializing and comparing the result. Unfortunately blocks currently compare with an extremely strict mode. Even a small class addition for change for completely equivalent markup/styling, is enough to cause the following scary error:

Screen Shot 2019-10-31 at 10 21 49 AM

Clicking on the primary action usually isn't what the user wants. It converts the previously nice to understand block into a plain HTML block:

Screen Shot 2019-10-31 at 10 21 56 AM

The best action is usually "Attempt Block Recovery" or "Convert to Blocks"

Screen Shot 2019-10-31 at 10 23 29 AM

Traditionally WP allows manipulation of content from a variety of filters/customizations, so this is a very easy case to fall into.

@gwwar
Copy link
Contributor Author

gwwar commented Dec 5, 2019

Nice Matias also pointed out a related issue in WordPress/gutenberg#7604

I think we can potentially add try PRs in parallel with our wpcom work and chat with the community on better CTAs, smarter validation and better overall user experience.

@gwwar gwwar changed the title Gutenberg: When Block Is Invalidated Perform Attempt Block Recovery Gutenberg: Investigate improvements when Block Is Invalidated Dec 11, 2019
@mmtr
Copy link
Member

mmtr commented Dec 16, 2019

See if core contributions are possible to make block validation both more relaxed and bulletproof (additive attributes/whitespace differences for example should be okay)

After reading all comments in WordPress/gutenberg#7604, I think the community could benefit from having 2 validation modes:

  • Strict: the current one that marks a block as invalid if it is not an exact match.
  • Moderate: allows extra attributes, as long as the ones provided by the save function are not altered (i.e. additional classes, data-* attributes, etc). It could still warns the differences in the browser console, and shows a tiny icon as a UI indicator that displays those differences when hovering it.

The strict mode will be the default one, allowing developers to switch to the moderate mode with a new Gutenberg setting in WP Admin.

For technical reference, the current strict mode is implemented in the isEquivalentHTML function.

@gwwar gwwar assigned gwwar and unassigned gwwar Dec 19, 2019
@gwwar
Copy link
Contributor Author

gwwar commented Dec 19, 2019

Actually will close this one out since we have a few PRs up

@gwwar gwwar closed this as completed Dec 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Goal] Gutenberg Working towards full integration with Gutenberg [Type] Enhancement
Projects
None yet
Development

No branches or pull requests

2 participants