Skip to content

Commit

Permalink
Patterns: Render draggable only when enabled (WordPress#63715)
Browse files Browse the repository at this point in the history
Co-authored-by: tyxla <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
  • Loading branch information
3 people authored Jul 19, 2024
1 parent dc41a6e commit ed11e6f
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ const InserterDraggableBlocks = ( {
useDispatch( blockEditorStore )
);

if ( ! isEnabled ) {
return children( {
draggable: false,
onDragStart: undefined,
onDragEnd: undefined,
} );
}

return (
<Draggable
__experimentalTransferDataType="wp-blocks"
Expand Down Expand Up @@ -72,9 +80,9 @@ const InserterDraggableBlocks = ( {
>
{ ( { onDraggableStart, onDraggableEnd } ) => {
return children( {
draggable: isEnabled,
onDragStart: isEnabled ? onDraggableStart : undefined,
onDragEnd: isEnabled ? onDraggableEnd : undefined,
draggable: true,
onDragStart: onDraggableStart,
onDragEnd: onDraggableEnd,
} );
} }
</Draggable>
Expand Down

0 comments on commit ed11e6f

Please sign in to comment.