-
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
Fix template part area variation matching #49500
Conversation
…o ensure they can all be registered
@jameskoster Unfortunately this does introduce a separate issue. Now that the variations work correctly this situation can occur in the block inserter: Here you have 'Header' and 'Footer' variations for inserting new empty template parts for those areas. There are also 'Header' and 'Footer' template parts for inserting existing template parts with those names. Some possibilities for resolving this:
|
Flaky tests detected in 7f785ba. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4616504085
|
Thanks for the PR 🙏 Good spot with that duplication issue in the Inserter.
I suspect something like this may happen naturally as we explore #48458 in more detail, but that's a little way off.
This seems like the better short-term approach to me. Otherwise this is working as expected: |
Just referencing #35453, which may need to be closed as wontfix as a result of this one. Which is probably fine, for simplicity, it seems okay to move this forward. The purple has helped a lot in making the reusable pieces feel as such. |
I think that's a better approach, given the insertion flow for these variations with targeted patterns etc.. |
I think that gets a bit tricky. A user is unlikely to understand the difference between two blocks called "Header", even if they have different icons. I'd also say that once you've created a header or two, it's much more likely you'd want to insert one of those directly, rather than inserting the empty instance and selecting from there. IE the value of the empty Header template part goes down quite a bit. The only reason I can think to insert the empty instances would be to create a new template part from scratch. If this is the route we want to go down, then I think it might be better to repurpose those blocks to be more about creating new template parts. This was proposed a little while ago in #31746. The designs are a bit out-of-date, but it communicates the idea. |
f23421a
to
7f785ba
Compare
I've updated the PR to hide the inserter variations for areas when a matching instance is found for that area.
Oh yeah, forgot about that one, I never did get it working in a satisfactory way. I'll remove my assignment myself for now, but it'd be worth taking a look at it with fresh eyes. |
What?
Fixes #45935
Ensures template part semantic variations are shown correctly.
Why?
This was a regression
How?
Template parts have two different categories of variations. Area variations and instance variations.
The problem was that both area and instance variations can have the same
name
('header' or 'footer'), and the name for block variations should be unique. When registering the variations, the first 'header' area variation was being registered correctly, but the 'header' instance variation failed to be registered due to an existing variation with that name.The variation match function then failed because it prioritises matching by an instance's slug (since #45672), and the 'header' instance variation failed to be registered.
The fix is to add unique names for area template part variations and instance template part variations, so they can peacefully co-exist.
After feedback, this PR now also avoids showing the area variation in the inserter when a matching instance variation exists.
Testing Instructions
Screenshots or screencast