-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Template Parts: Add a replace flow to the inspector controls #55128
Conversation
Size Change: +217 B (0%) Total Size: 1.7 MB
ℹ️ View Unchanged
|
Flaky tests detected in fc12186. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/8007028292
|
49ce2ef
to
20cb955
Compare
This is what we are doing :) |
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
mapTemplatePartToBlockPattern( templatePart ) | ||
); | ||
|
||
const onTemplatePartSelect = ( templatePart ) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also defined in packages/block-library/src/template-part/edit/selection-modal.js, but I think they are simple enough that it's ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor comment but this is looking good to me!
919083f
to
b9959b2
Compare
This is cool. I feel like there's some relationship between this PR and the shuffling PR #59251 |
The perf here is still not good. On an M1 it takes seconds for the async list to show more possibilities. Maybe we need also a visual indicator in place. Plus that the UI is still frozen for a bit. |
That way works too but I was thinking about the other way around: adding a shuffle button to the block toolbar of the template part and use the "replace list" as alternative options. |
templatePartId | ||
); | ||
const blockPatterns = useAlternativeBlockPatterns( area, clientId ); | ||
const hasReplacements = !! templateParts.length || !! blockPatterns.length; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sort of reverted the changes I made here: #57856. I'll make a PR to fix it.
What?
This exposes the option to replace a template part with another, from the inspector controls for the block. This is similar to the idea in #44582.
Why?
It's already possible to do this, using the "replace" option in the More Settings for the block in the toolbar, but this isn't very discoverable, so adding it to the inspector controls makes it easier to do.
How?
Just add block previews in the sidebar and then hook them up to the setAttribute function to switch the slugs for the template part.
Testing Instructions
Screenshots or screencast
Questions