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

Block lib: image: remove useless border props #57225

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions packages/block-library/src/image/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
MediaPlaceholder,
useBlockProps,
store as blockEditorStore,
__experimentalUseBorderProps as useBorderProps,
useBlockEditingMode,
} from '@wordpress/block-editor';
import { useEffect, useRef, useState } from '@wordpress/element';
Expand Down Expand Up @@ -314,16 +313,10 @@ export function ImageEdit( {
/>
);

const borderProps = useBorderProps( attributes );

const classes = classnames( className, {
'is-transient': temporaryURL,
'is-resized': !! width || !! height,
[ `size-${ sizeSlug }` ]: sizeSlug,
'has-custom-border':
!! borderProps.className ||
( borderProps.style &&
Object.keys( borderProps.style ).length > 0 ),
} );

const blockProps = useBlockProps( {
Expand All @@ -335,10 +328,7 @@ export function ImageEdit( {
const placeholder = ( content ) => {
return (
<Placeholder
className={ classnames( 'block-editor-media-placeholder', {
[ borderProps.className ]:
!! borderProps.className && ! isSelected,
} ) }
className="block-editor-media-placeholder"
withIllustration={ true }
icon={ icon }
label={ __( 'Image' ) }
Expand All @@ -353,7 +343,6 @@ export function ImageEdit( {
width: height && aspectRatio ? '100%' : width,
height: width && aspectRatio ? '100%' : height,
objectFit: scale,
...borderProps.style,
} }
>
{ content }
Expand Down
7 changes: 0 additions & 7 deletions packages/block-library/src/image/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {
store as blockEditorStore,
useSettings,
__experimentalImageEditor as ImageEditor,
__experimentalUseBorderProps as useBorderProps,
privateApis as blockEditorPrivateApis,
} from '@wordpress/block-editor';
import { useEffect, useMemo, useState, useRef } from '@wordpress/element';
Expand Down Expand Up @@ -567,9 +566,6 @@ export default function Image( {
defaultedAlt = __( 'This image has an empty alt attribute' );
}

const borderProps = useBorderProps( attributes );
const isRounded = attributes.className?.includes( 'is-style-rounded' );

let img = (
// Disable reason: Image itself is not meant to be interactive, but
// should direct focus to block.
Expand All @@ -586,14 +582,12 @@ export default function Image( {
} );
} }
ref={ imageRef }
className={ borderProps.className }
style={ {
width:
( width && height ) || aspectRatio ? '100%' : undefined,
height:
( width && height ) || aspectRatio ? '100%' : undefined,
objectFit: scale,
...borderProps.style,
} }
/>
{ temporaryURL && <Spinner /> }
Expand Down Expand Up @@ -622,7 +616,6 @@ export default function Image( {
onFinishEditing={ () => {
setIsEditingImage( false );
} }
borderProps={ isRounded ? undefined : borderProps }
/>
</ImageWrapper>
);
Expand Down