Site Editor: Fix template part area listing when a template has no edits#55085
Site Editor: Fix template part area listing when a template has no edits#55085
Conversation
youknowriad
left a comment
There was a problem hiding this comment.
We keep discovering side effects. Thanks for the fix.
I'm guessing we need to look deeply at these "transient edits" at some point. Maybe initialize them on load or something.
|
Size Change: +254 B (0%) Total Size: 1.65 MB
ℹ️ View Unchanged
|
That would be great! As you mentioned in the original PR, old behavior wasn't guaranteed for all entities. The change made it more or less the same for everyone - check the I guess, in the end, it's all about consumer expectations and clear rules 😅 |
|
Flaky tests detected in 8785d65. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6427752168
|
andrewserong
left a comment
There was a problem hiding this comment.
Thanks for looking into a fix @Mamaduka! Overall this is looking good for displaying the areas again:
| Before | After |
|---|---|
![]() |
![]() |
Just left a couple of comments about a tiny typo in the tests.
Unfortunately I think due to calling parse() we wind up with different clientIds for the parsed blocks, so the resulting buttons in the template sidebar no longer work for clicking through to the associated block. In WP 6.3 clicking these would take you to the block in question 🤔
One option, if it seems too difficult to map back to the real block in the template, could be to only render as buttons if we were able to get the "real" blocks?
| } | ||
|
|
||
| return record?.content && typeof record.content !== 'function' | ||
| ? parse( record.content ) |
There was a problem hiding this comment.
Sorry, I didn't hit submit on my review comment for this line. I think this results in a clientId that doesn't match the existing blocks within the template, which means that the template area buttons no longer link back to the block in the template. I'm assuming a little here, so apologies if it's not what's causing it!
2023-10-06.12.15.09.mp4
In 6.3, the buttons link to the template part:
2023-10-06.12.21.51.mp4
There was a problem hiding this comment.
Good catch, @andrewserong! I forgot to test the Document settings sidebar and missed the issue.
You're right. Parsing the content separately will cause the clientId miss-match. I will start looking for a solution.
Co-authored-by: Andrew Serong <14988353+andrewserong@users.noreply.github.com>
|
Created an alternative fix for the issue - #55115. |
|
Closing in favor of #55115. |


What?
Fixes #55061.
PR fixes the
getCurrentTemplateTemplatePartsselector returning an empty value when a template has no edits.This is probably a side-effect of #52417.
Update: If anyone is wondering why areas are displayed when a template has no edits at all (loaded from the file). This is due to blocks like Query and
core/patternperforming updates on the initial load. This loadsblocksin the store.Why?
A record returned by
getEditedEntityRecordwill have an undefinedblockproperty when an entity has no edits. In the past, blocks were loaded into the store for a current recond viauseEntityBlockEditor. This isn't the case anymore.How?
Adds a helper
getBlocksFromRecordmethod, which returns blocks from a record based on available values.Testing Instructions
Screenshots or screencast