Skip to content

Commit

Permalink
Fix: Not possible to resize cover (#22349)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefilipecosta authored May 14, 2020
1 parent 75970bf commit ead98ed
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions packages/block-library/src/cover/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ const RESIZABLE_BOX_ENABLE_OPTION = {

function ResizableCover( {
className,
children,
onResizeStart,
onResize,
onResizeStop,
...props
} ) {
const [ isResizing, setIsResizing ] = useState( false );

Expand All @@ -154,24 +154,23 @@ function ResizableCover( {
'is-resizing': isResizing,
} ) }
enable={ RESIZABLE_BOX_ENABLE_OPTION }
onResizeStart={ ( event, direction, elt ) => {
onResizeStart={ ( _event, _direction, elt ) => {
onResizeStart( elt.clientHeight );
onResize( elt.clientHeight );
} }
onResize={ ( event, direction, elt ) => {
onResize={ ( _event, _direction, elt ) => {
onResize( elt.clientHeight );
if ( ! isResizing ) {
setIsResizing( true );
}
} }
onResizeStop={ ( event, direction, elt ) => {
onResizeStop={ ( _event, _direction, elt ) => {
onResizeStop( elt.clientHeight );
setIsResizing( false );
} }
minHeight={ COVER_MIN_HEIGHT }
>
{ children }
</ResizableBox>
{ ...props }
/>
);
}

Expand Down Expand Up @@ -471,12 +470,8 @@ function CoverEdit( {
<>
{ controls }
<ResizableCover
className={ classnames(
'block-library-cover__resize-container',
{
'is-selected': isSelected,
}
) }
showHandle={ isSelected }
className="block-library-cover__resize-container"
onResizeStart={ () => {
setAttributes( { minHeightUnit: 'px' } );
toggleSelection( false );
Expand Down

0 comments on commit ead98ed

Please sign in to comment.