-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Cover: Avoid content loss when the templateLock value is all or contentOnly #45632
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Open in CodeSandbox Web Editor | VS Code | VS Code Insiders |
Mamaduka
requested review from
ndiego and
youknowriad
and removed request for
ajitbohra
November 9, 2022 16:29
Mamaduka
added
[Type] Bug
An existing feature does not function as intended
[Block] Cover
Affects the Cover Block - used to display content laid over a background image
labels
Nov 9, 2022
Mamaduka
commented
Nov 9, 2022
Size Change: +601 B (0%) Total Size: 1.29 MB
ℹ️ View Unchanged
|
ndiego
approved these changes
Nov 9, 2022
The fix is correct but there's indeed a reflexion to be had for the future on these props. It seems we might need two kind of templates: initialTemplate and a regular template prop. |
youknowriad
approved these changes
Nov 10, 2022
Mamaduka
added
the
Backport to WP Minor Release
Pull request that needs to be backported to a WordPress minor release
label
Nov 10, 2022
Thanks for the reviews, @ndiego, and @youknowriad! |
Mamaduka
added a commit
that referenced
this pull request
Nov 10, 2022
…ntOnly (#45632) * Cover: Avoid content loss when the templateLock value is all or contentOnly * Add inline comment
Mamaduka
added a commit
that referenced
this pull request
Nov 10, 2022
…ntOnly (#45632) * Cover: Avoid content loss when the templateLock value is all or contentOnly * Add inline comment
Mamaduka
removed
the
Backport to WP Minor Release
Pull request that needs to be backported to a WordPress minor release
label
Nov 14, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
[Block] Cover
Affects the Cover Block - used to display content laid over a background image
[Type] Bug
An existing feature does not function as intended
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What?
Resolves #45625.
PR fixes the content loss bug when a Cover block has the
templateLock
attribute set toall
orcontentOnly
.Why?
The
useInnerBlockTemplateSync
hook will try to replace inner blocks with the default template when the template is meant to be locked.It ensures templates are always in sync, which is handy for post-type templates in the editor. But it can cause content loss when a block has a default template, and
templateLock
can be defined directly on it.How?
We can skip synchronizing by omitting the default template when a Cover already has inner blocks.
Ideally, we might want to adjust
shouldApplyTemplate
inside theuseInnerBlockTemplateSync
, but that's a significant change for a minor release patch.Testing Instructions
See the original issue for reproduction steps - #45625.
Also, confirm that the default template is correctly inserted for a new Cover block.