Skip to content

Commit

Permalink
Remove caption restriction in pattern overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
SantosGuillamot committed Jul 1, 2024
1 parent ac597ee commit be4c4c2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
3 changes: 1 addition & 2 deletions packages/block-editor/src/hooks/use-bindings-attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,8 @@ export const withBlockBindingSupport = createHigherOrderComponent(
) &&
Object.keys( keptAttributes ).length
) {
// Don't update caption and href until they are supported.
// Don't update href until they are supported.
if ( hasPatternOverridesDefaultBinding ) {
delete keptAttributes?.caption;
delete keptAttributes?.href;
}
setAttributes( keptAttributes );
Expand Down
10 changes: 2 additions & 8 deletions packages/block-library/src/image/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,6 @@ export default function Image( {
lockAltControlsMessage,
lockTitleControls = false,
lockTitleControlsMessage,
lockCaption = false,
hideCaptionControls = false,
} = useSelect(
( select ) => {
Expand Down Expand Up @@ -491,10 +490,6 @@ export default function Image( {
// Disable editing the link of the URL if the image is inside a pattern instance.
// This is a temporary solution until we support overriding the link on the frontend.
hasParentPattern || arePatternOverridesEnabled,
lockCaption:
// Disable editing the caption if the image is inside a pattern instance.
// This is a temporary solution until we support overriding the caption on the frontend.
hasParentPattern,
lockAltControls:
!! altBinding &&
! altBindingSource?.canUserEditValue( {
Expand Down Expand Up @@ -1002,10 +997,9 @@ export default function Image( {
label={ __( 'Image caption text' ) }
showToolbarButton={
isSingleSelected &&
hasNonContentControls &&
! arePatternOverridesEnabled
( hasNonContentControls || isContentOnlyMode ) &&
! hideCaptionControls
}
readOnly={ lockCaption }
/>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,12 @@ function PatternOverridesControls( {
}

const hasUnsupportedImageAttributes =
blockName === 'core/image' &&
( !! attributes.caption?.length || !! attributes.href?.length );
blockName === 'core/image' && !! attributes.href?.length;

const helpText =
! hasOverrides && hasUnsupportedImageAttributes
? __(
`Overrides currently don't support image captions or links. Remove the caption or link first before enabling overrides.`
`Overrides currently don't support image links. Remove the link first before enabling overrides.`
)
: __(
'Allow changes to this block throughout instances of this pattern.'
Expand Down

0 comments on commit be4c4c2

Please sign in to comment.