-
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
Pattern block: Try adding Pattern Part block #50899
Closed
Closed
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
glendaviesnz
added
[Feature] Patterns
A collection of blocks that can be synced (previously reusable blocks) or unsynced
[Block] Pattern
Affects the Patterns Block
labels
May 24, 2023
Size Change: +301 B (0%) Total Size: 1.41 MB
ℹ️ View Unchanged
|
Flaky tests detected in 7d5160f. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5064805381
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
[Block] Pattern
Affects the Patterns Block
[Feature] Patterns
A collection of blocks that can be synced (previously reusable blocks) or unsynced
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?
Adds a Pattern Part block that is wrapped around every block within a Pattern
Why?
Just as an experiment to see if it was a potential way to add fine-grained control over each part of a partially synced pattern
The vague theory was that each Pattern Part block could be responsible for saving any local changes to the block as apposed to pushing all the content changes up to the parent Pattern block attributes as proposed here. This could potentially remove the need for complex ids/refs/addressing to track which blocks with the pattern the content relates to.
But Although it is relatively easy to add these wrapper blocks, it causes a lot of layout issues in the editor due to extra divs. There may be a way to make them useful without adding divs for them in the editor, but there is also the issue of how to get the child block to push its attributes up to the Pattern Part block without being aware that it is in fact wrapped. It would be possible to monkey patch the setting of attributes as here, but that won't work if a block uses
updateBlockAttributes
fromuseDispatch
for some reason.Going to shelve for now, but adding as a PR as a record of what was explored.
How?
When loading a Pattern block in the editor all of the innerBlocks are recursed and the Pattern Part block wrapper is added.
Testing Instructions
<!-- wp:pattern {"slug":"twentytwentythree/cta","syncStatus":"partial"} /-->
Testing Instructions for Keyboard
Screenshots or screencast