Skip to content
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

Pattern overrides: use block binding editing API #60721

Merged
merged 44 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
78f9601
Pattern overrides: use block binding editing API
ellatrix May 9, 2024
17b31b8
Update only the needed attributes with bindings
SantosGuillamot May 9, 2024
63c6b6d
Keep blocks as normal when editing pattern
SantosGuillamot May 9, 2024
46063db
Use inner blocks for set edit mode
SantosGuillamot May 9, 2024
f1f78ae
Change indiviual reset logic
SantosGuillamot May 9, 2024
8121723
Move variable after early return
SantosGuillamot May 9, 2024
ec4daec
Add inline comment for bindings setAttributes
SantosGuillamot May 9, 2024
35aa0ab
Change variable to isOverriden
SantosGuillamot May 9, 2024
a71ba38
Change missing isOverriden
SantosGuillamot May 9, 2024
29afc1f
Fix detaching of synced patterns
SantosGuillamot May 9, 2024
31bf94c
Sync values of bound attributes
SantosGuillamot May 9, 2024
6c60eb3
Adapt synced pattern tests
SantosGuillamot May 9, 2024
49b062a
Use overriden values when detaching pattern
SantosGuillamot May 9, 2024
766a762
Adapt pattern-overrides tests
SantosGuillamot May 9, 2024
49286e1
Add workaround for pattern overrides
SantosGuillamot May 9, 2024
ef29ab3
Don't update non-bound attributes when using patterns
SantosGuillamot May 9, 2024
ba8b618
Add test for blocks with a shared name
SantosGuillamot May 9, 2024
e695fb4
Support button rel in bindings editor logic
SantosGuillamot May 9, 2024
d9d9fd6
Solve undo/redo issues
SantosGuillamot May 9, 2024
4a4465f
Stop using syncDerivedUpdates
SantosGuillamot May 9, 2024
1101667
Ensure change is marked as persistent in pattern overrides
SantosGuillamot May 9, 2024
a95749f
Try to solve undo/redo issues
SantosGuillamot May 9, 2024
e2a1b8a
Manage undefined attrs in pattern overrides
SantosGuillamot May 9, 2024
9d444a3
Remove `content` pattern property if empty
SantosGuillamot May 9, 2024
e28da53
Remove pattern-overrides specific code from `withBlockBindingSupport`…
talldan May 13, 2024
ae534d8
Fix persistent issues with setValues API
ellatrix May 13, 2024
4ec7315
Fall back to ''
ellatrix May 13, 2024
3a7311d
Make sure any previous changes are persisted before resetting.
ellatrix May 13, 2024
e013f6d
Add undo/redo test for resetting
kevin940726 May 13, 2024
950aab9
Fix test... 🤦
kevin940726 May 13, 2024
d99ecb7
Fix remaining undo test
ellatrix May 13, 2024
9ec9bba
Fix individual reset
ellatrix May 13, 2024
7d72a34
Add test for undoing loses the focus
kevin940726 May 13, 2024
4ebdb09
Fix reset button test
ellatrix May 13, 2024
44b51dd
Simplify pattern synced blocks test
SantosGuillamot May 13, 2024
5975f74
Remove focus test
SantosGuillamot May 13, 2024
10fa4e8
Use getBlockParentsByBlockName
SantosGuillamot May 14, 2024
3cfdd44
Add early return if blockName doesn't exist
SantosGuillamot May 14, 2024
8c5f574
Add comment for undefined values
SantosGuillamot May 14, 2024
3866446
Remove comment typo
SantosGuillamot May 14, 2024
33bfb86
Remove unnecessary includeHidden from tests
SantosGuillamot May 14, 2024
d80aba7
Check the frontend in patterns test
SantosGuillamot May 14, 2024
6b97321
Check frontend in updated pattern
SantosGuillamot May 14, 2024
c122b79
Stop using `getPatternRecord`
SantosGuillamot May 14, 2024
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use getBlockParentsByBlockName
  • Loading branch information
SantosGuillamot committed May 14, 2024
commit 10fa4e8df34e2c5ba8b719227f5f0a3c9959c950
18 changes: 10 additions & 8 deletions packages/editor/src/bindings/pattern-overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ export default {
name: 'core/pattern-overrides',
label: _x( 'Pattern Overrides', 'block bindings source' ),
getValue( { registry, clientId, attributeName } ) {
const { getBlockAttributes, getBlockParents, getBlockName } =
const { getBlockAttributes, getBlockParentsByBlockName } =
registry.select( blockEditorStore );
const currentBlockAttributes = getBlockAttributes( clientId );
const parents = getBlockParents( clientId, true );
const patternClientId = parents.find(
( id ) => getBlockName( id ) === 'core/block'
const [ patternClientId ] = getBlockParentsByBlockName(
clientId,
'core/block',
true
);

const overridableValue =
Expand All @@ -31,12 +32,13 @@ export default {
return overridableValue === '' ? undefined : overridableValue;
},
setValues( { registry, clientId, attributes } ) {
const { getBlockAttributes, getBlockParents, getBlockName, getBlocks } =
const { getBlockAttributes, getBlockParentsByBlockName, getBlocks } =
registry.select( blockEditorStore );
const currentBlockAttributes = getBlockAttributes( clientId );
const parents = getBlockParents( clientId, true );
const patternClientId = parents.find(
( id ) => getBlockName( id ) === 'core/block'
const [ patternClientId ] = getBlockParentsByBlockName(
clientId,
'core/block',
true
);
// If there is no pattern client ID, sync blocks with the same name and same attributes.
if ( ! patternClientId ) {
Expand Down
18 changes: 10 additions & 8 deletions packages/patterns/src/components/reset-overrides-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ export default function ResetOverridesControl( props ) {
return;
}

const { getBlockAttributes, getBlockParents, getBlockName } =
const { getBlockAttributes, getBlockParentsByBlockName } =
select( blockEditorStore );
const parents = getBlockParents( props.clientId, true );
const patternClientId = parents.find(
( id ) => getBlockName( id ) === 'core/block'
const [ patternClientId ] = getBlockParentsByBlockName(
props.clientId,
'core/block',
true
);

if ( ! patternClientId ) {
Expand All @@ -43,11 +44,12 @@ export default function ResetOverridesControl( props ) {
);

function onClick() {
const { getBlockAttributes, getBlockParents, getBlockName } =
const { getBlockAttributes, getBlockParentsByBlockName } =
registry.select( blockEditorStore );
const parents = getBlockParents( props.clientId, true );
const patternClientId = parents.find(
( id ) => getBlockName( id ) === 'core/block'
const [ patternClientId ] = getBlockParentsByBlockName(
props.clientId,
'core/block',
true
);

if ( ! patternClientId ) {
Expand Down