Skip to content

Commit

Permalink
fixes from review
Browse files Browse the repository at this point in the history
  • Loading branch information
Glen Davies committed Oct 12, 2020
1 parent 7c0eff0 commit 0c1daa3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 24 deletions.
37 changes: 15 additions & 22 deletions packages/block-library/src/image/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export function ImageEdit( {
insertBlocksAfter,
noticeOperations,
onReplace,
context,
context: { allowAlign = true, allowResize = true, isList = false },
} ) {
const {
url = '',
Expand All @@ -91,7 +91,6 @@ export function ImageEdit( {
width,
height,
sizeSlug,
isListItem,
} = attributes;

const altRef = useRef();
Expand All @@ -110,12 +109,6 @@ export function ImageEdit( {
return getSettings().mediaUpload;
} );

const allowResize =
context.allowResize !== undefined ? context.allowResize : true;

const allowAlign =
context.allowBlockAlign !== undefined ? context.allowBlockAlign : true;

function onUploadError( message ) {
noticeOperations.removeAllNotices();
noticeOperations.createErrorNotice( message );
Expand Down Expand Up @@ -271,10 +264,10 @@ export function ImageEdit( {
}, [ isTemp ] );

useEffect( () => {
if ( context?.isList ) {
setAttributes( { isListItem: context.isList } );
if ( isList ) {
setAttributes( { isListItem: isList } );
}
}, [ context ] );
}, [ isList ] );

const isExternal = isExternalImage( id, url );
const controls = (
Expand Down Expand Up @@ -339,7 +332,7 @@ export function ImageEdit( {
/>
);

if ( isListItem ) {
if ( isList ) {
return (
<>
{ controls }
Expand All @@ -351,17 +344,17 @@ export function ImageEdit( {
</li>
</>
);
} else {
return (
<>
{ controls }
<figure { ...blockProps }>
{ image }
{ mediaPlaceholder }
</figure>
</>
);
}

return (
<>
{ controls }
<figure { ...blockProps }>
{ image }
{ mediaPlaceholder }
</figure>
</>
);
}

export default withNotices( ImageEdit );
4 changes: 2 additions & 2 deletions packages/block-library/src/image/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default function save( { attributes } ) {
</>
);

if ( true === isListItem ) {
if ( isListItem ) {
return (
<li { ...useBlockProps.save() }>
<figure className={ classes }>{ figure }</figure>
Expand All @@ -83,7 +83,7 @@ export default function save( { attributes } ) {
}

return (
<figure className={ classes } { ...useBlockProps.save() }>
<figure { ...useBlockProps.save( { className: classes } ) }>
{ figure }
</figure>
);
Expand Down

0 comments on commit 0c1daa3

Please sign in to comment.