-
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
Fix nested pattern overrides and disable editing inner pattern #58541
Conversation
@@ -309,7 +322,6 @@ export default function ReusableBlockEdit( { | |||
}, [ syncDerivedUpdates, patternClientId, registry, setAttributes ] ); | |||
|
|||
const handleEditOriginal = ( event ) => { | |||
setBlockEditMode( setBlockEditingMode, innerBlocks, 'default' ); |
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 removed because we no longer need it.
Size Change: +29 B (0%) Total Size: 1.69 MB
ℹ️ View Unchanged
|
e46fb28
to
b64dcde
Compare
This comment was marked as outdated.
This comment was marked as outdated.
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 Core SVNIf you're a Core Committer, use this list when committing to
GitHub Merge commitsIf 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. |
b64dcde
to
29b11fa
Compare
I thought I posted a comment on this last week, but don't see it now 🤔 This is testing well for me in the editor, but changes to the nested pattern overrides do not show in the frontend for me still - but I think you might still be working on that. |
29b11fa
to
c15d464
Compare
@glendaviesnz Could you test it again with the latest WP core? I just tested it and the e2e test passed on CI as well. |
c15d464
to
adfe948
Compare
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 working really well for me, just a few small comments, but nothing major.
(edit: to confirm, I didn't have the issues @glendaviesnz noticed, and I used a fairly up-to-date verison of WordPress trunk)
@@ -134,6 +135,7 @@ function getContentValuesFromInnerBlocks( blocks, defaultValues ) { | |||
/** @type {Record<string, { values: Record<string, unknown>}>} */ | |||
const content = {}; | |||
for ( const block of blocks ) { | |||
if ( block.name === blockName ) continue; |
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.
I think this check could be clearer to the reader (I had to scroll up to find where blockName
comes from to understand what value it has).
Perhaps calling it patternBlockName
or adding a comment above this code could help.
@@ -250,7 +260,9 @@ export default function ReusableBlockEdit( { | |||
// Apply the initial overrides from the pattern block to the inner blocks. | |||
useEffect( () => { | |||
defaultContent.current = {}; | |||
const editingMode = getBlockEditingMode( patternClientId ); | |||
const { getBlockEditingMode } = registry.select( blockEditorStore ); |
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.
Why use registry.select
here over the alternatives?
It might be worth explaining it in a comment.
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.
It's basically the same thing as the alternative (using getBlockEditingMode
from useSelect
). I don't mind switching over just to make it easier to understand though!
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.
No real preference for me, just my curiosity.
39f57c0
to
6807f0d
Compare
What?
Alternative to #58359. Fix #58291.
This PR does a few things:
The first two are the same with #58359. This PR also fixes the fourth but it's just a nice-to-have.
Why?
To prevent unexpected broken page. See #58291.
How?
Just some small refactorings.
Testing Instructions
Added an e2e test.
Screenshots or screencast