Skip to content

Commit

Permalink
Place the link to post ToggleControl inside a ToolsPanelItem
Browse files Browse the repository at this point in the history
  • Loading branch information
carolinan committed May 23, 2024
1 parent 2c4d2f3 commit e0d8001
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions packages/block-library/src/media-text/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ function MediaTextEdit( {
focalPoint: undefined,
mediaWidth: 50,
mediaSizeSlug: undefined,
featuredImageLink: false,
} );
} }
dropdownMenuProps={ TOOLSPANEL_DROPDOWNMENU_PROPS }
Expand Down Expand Up @@ -415,8 +416,7 @@ function MediaTextEdit( {
/>
) }
{ useFeaturedImage && (
<ToggleControl
__nextHasNoMarginBottom
<ToolsPanelItem
label={
postTypeName
? sprintf(
Expand All @@ -426,13 +426,31 @@ function MediaTextEdit( {
)
: __( 'Link to post' )
}
onChange={ () =>
setAttributes( {
featuredImageLink: ! featuredImageLink,
} )
isShownByDefault
hasValue={ () => featuredImageLink }
onDeselect={ () =>
setAttributes( { featuredImageLink: false } )
}
checked={ featuredImageLink }
/>
>
<ToggleControl
__nextHasNoMarginBottom
label={
postTypeName
? sprintf(
// translators: %s: Name of the post type e.g: "Page".
__( 'Link to %s' ),
postTypeName
)
: __( 'Link to post' )
}
onChange={ () =>
setAttributes( {
featuredImageLink: ! featuredImageLink,
} )
}
checked={ featuredImageLink }
/>
</ToolsPanelItem>
) }
</ToolsPanel>
);
Expand Down

0 comments on commit e0d8001

Please sign in to comment.