-
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
Site Editor: Fix template part area listing when a template has no edits #55085
Conversation
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.
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
|
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.
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 clientId
s 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
getCurrentTemplateTemplateParts
selector 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/pattern
performing updates on the initial load. This loadsblocks
in the store.Why?
A record returned by
getEditedEntityRecord
will have an undefinedblock
property 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
getBlocksFromRecord
method, which returns blocks from a record based on available values.Testing Instructions
Screenshots or screencast