Skip to content

Commit b9db3e1

Browse files
talldankevin940726
authored andcommitted
Ensure "disable overrides" button is active for image blocks with captions or links (#62948)
Co-authored-by: talldan <talldanwp@git.wordpress.org> Co-authored-by: kevin940726 <kevin940726@git.wordpress.org>
1 parent 6155b66 commit b9db3e1

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

packages/patterns/src/components/pattern-overrides-controls.js

+14-11
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function PatternOverridesControls( {
4444

4545
const hasName = !! attributes.metadata?.name;
4646
const defaultBindings = attributes.metadata?.bindings?.__default;
47-
const allowOverrides =
47+
const hasOverrides =
4848
hasName && defaultBindings?.source === PATTERN_OVERRIDES_BINDING_SOURCE;
4949
const isConnectedToOtherSources =
5050
defaultBindings?.source &&
@@ -79,13 +79,14 @@ function PatternOverridesControls( {
7979
blockName === 'core/image' &&
8080
( !! attributes.caption?.length || !! attributes.href?.length );
8181

82-
const helpText = hasUnsupportedImageAttributes
83-
? __(
84-
`Overrides currently don't support image captions or links. Remove the caption or link first before enabling overrides.`
85-
)
86-
: __(
87-
'Allow changes to this block throughout instances of this pattern.'
88-
);
82+
const helpText =
83+
! hasOverrides && hasUnsupportedImageAttributes
84+
? __(
85+
`Overrides currently don't support image captions or links. Remove the caption or link first before enabling overrides.`
86+
)
87+
: __(
88+
'Allow changes to this block throughout instances of this pattern.'
89+
);
8990

9091
return (
9192
<>
@@ -101,16 +102,18 @@ function PatternOverridesControls( {
101102
variant="secondary"
102103
aria-haspopup="dialog"
103104
onClick={ () => {
104-
if ( allowOverrides ) {
105+
if ( hasOverrides ) {
105106
setShowDisallowOverridesModal( true );
106107
} else {
107108
setShowAllowOverridesModal( true );
108109
}
109110
} }
110-
disabled={ hasUnsupportedImageAttributes }
111+
disabled={
112+
! hasOverrides && hasUnsupportedImageAttributes
113+
}
111114
__experimentalIsFocusable
112115
>
113-
{ allowOverrides
116+
{ hasOverrides
114117
? __( 'Disable overrides' )
115118
: __( 'Enable overrides' ) }
116119
</Button>

0 commit comments

Comments
 (0)