[wp-trac] [WordPress Trac] #62069: Block Bindings: block doesn't receive full __default bindings during render

WordPress Trac noreply at wordpress.org
Wed Sep 18 10:09:53 UTC 2024


#62069: Block Bindings: block doesn't receive full __default bindings during render
----------------------------------------+------------------------
 Reporter:  talldanwp                   |       Owner:  talldanwp
     Type:  defect (bug)                |      Status:  assigned
 Priority:  normal                      |   Milestone:  6.7
Component:  Editor                      |     Version:  6.6
 Severity:  normal                      |  Resolution:
 Keywords:  has-patch needs-unit-tests  |     Focuses:
----------------------------------------+------------------------
Description changed by talldanwp:

Old description:

> Original gutenberg issue -
> https://github.com/WordPress/gutenberg/issues/64688
>
> TLDR - some image block features don't work correctly when the image is
> using a pattern override due to some missing block bindings code in core.
>
> ----
> Longer explanation:
>
> The pattern overrides feature is built upon block bindings, and uses a
> special `__default` binding that means all block attributes that support
> binding are bound:
> {{{#!js
>
> bindings: {
>     __default: 'core/pattern-overrides'
> }
> }}}
>
> During processing of the bindings, this single `__default` binding is
> replaced with the individual binding attributes - e.g.:
> {{{#!js
>
> bindings: {
>     src: 'core/pattern-overrides',
>     id: 'core/pattern-overrides',
>     caption: 'core/pattern-overrides',
> }
> }}}
>
> In the gutenberg plugin these individual bindings are assigned back to
> the block before rendering so that the block can reason about which
> individual attributes are bound:
> https://github.com/WordPress/gutenberg/blob/98b8d415830fa9ebf7b4b0a2b95d65b9fd1e813a/lib/compat/wordpress-6.6/blocks.php#L40
>
> This allows blocks like the image block to check whether an individual
> attribute, like `id` has a binding:
> https://github.com/WordPress/gutenberg/blob/98b8d415830fa9ebf7b4b0a2b95d65b9fd1e813a/packages
> /block-library/src/image/index.php#L31
>
> Unfortunately core doesn't have the same logic to assign the individual
> bindings back to the block before rendering, which means the image
> block's logic fails. Any block that renders just receives the individual
> `__default` binding.

New description:

 Original gutenberg issue -
 https://github.com/WordPress/gutenberg/issues/64688

 TLDR - some image block features don't work correctly when the image is
 using a pattern override due to some missing block bindings code in core.

 ----
 Longer explanation:

 The pattern overrides feature is built upon block bindings, and uses a
 special `__default` binding that means all block attributes that support
 binding are bound:
 {{{#!js

 bindings: {
     __default: 'core/pattern-overrides'
 }
 }}}

 During processing of the bindings, this single `__default` binding is
 replaced with the individual binding attributes - e.g.:
 {{{#!js

 bindings: {
     src: 'core/pattern-overrides',
     id: 'core/pattern-overrides',
     caption: 'core/pattern-overrides',
 }
 }}}

 In the gutenberg plugin this updated bindings metadata is assigned back to
 the block before rendering so that the block can reason about which
 individual attributes are bound:
 https://github.com/WordPress/gutenberg/blob/98b8d415830fa9ebf7b4b0a2b95d65b9fd1e813a/lib/compat/wordpress-6.6/blocks.php#L40

 This allows blocks like the image block to check whether an individual
 attribute, like `id`, has a binding:
 https://github.com/WordPress/gutenberg/blob/98b8d415830fa9ebf7b4b0a2b95d65b9fd1e813a/packages
 /block-library/src/image/index.php#L31

 Unfortunately, WordPress core doesn't have the same logic to assign the
 updated binding metadata back to the block before rendering, which means
 the image block's logic fails. The block only receives the individual
 __default binding in its metadata.

--

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/62069#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list