Skip to content

Commit

Permalink
Disable the innerBlocks dropzones so drag drop works same as existing…
Browse files Browse the repository at this point in the history
… gallery - with the idea that we will improve the innerblocks drag and drop in a later PR
  • Loading branch information
Glen Davies committed Nov 5, 2020
1 parent 38ab027 commit cc05d60
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
4 changes: 3 additions & 1 deletion packages/block-editor/src/components/inner-blocks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ function UncontrolledInnerBlocks( props ) {
__experimentalAppenderTagName,
renderAppender,
orientation,
dropZonesDisabled,
placeholder,
__experimentalLayout: layout = defaultLayout,
} = props;
Expand All @@ -58,7 +59,8 @@ function UncontrolledInnerBlocks( props ) {
allowedBlocks,
templateLock,
captureToolbars,
orientation
orientation,
dropZonesDisabled,
);

useInnerBlockTemplateSync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export default function useNestedSettingsUpdate(
allowedBlocks,
templateLock,
captureToolbars,
orientation
orientation,
dropZonesDisabled,
) {
const { updateBlockListSettings } = useDispatch( 'core/block-editor' );

Expand Down Expand Up @@ -65,6 +66,9 @@ export default function useNestedSettingsUpdate(
if ( orientation !== undefined ) {
newSettings.orientation = orientation;
}
if ( dropZonesDisabled !== undefined ) {
newSettings.dropZonesDisabled = dropZonesDisabled;
}

if ( ! isShallowEqual( blockListSettings, newSettings ) ) {
updateBlockListSettings( clientId, newSettings );
Expand All @@ -77,6 +81,7 @@ export default function useNestedSettingsUpdate(
parentLock,
captureToolbars,
orientation,
dropZonesDisabled,
updateBlockListSettings,
] );
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,14 @@ export default function useBlockDropZone( {
} ) {
const [ targetBlockIndex, setTargetBlockIndex ] = useState( null );

const { isLockedAll, orientation } = useSelect(
const { isLockedAll, orientation, isDropZonesDisabled } = useSelect(
( select ) => {
const { getBlockListSettings, getTemplateLock } = select(
'core/block-editor'
);
return {
isDropZonesDisabled: getBlockListSettings( targetRootClientId )
?.dropZonesDisabled,
isLockedAll: getTemplateLock( targetRootClientId ) === 'all',
orientation: getBlockListSettings( targetRootClientId )
?.orientation,
Expand All @@ -119,7 +121,7 @@ export default function useBlockDropZone( {

const { position } = useDropZone( {
element,
isDisabled: isLockedAll,
isDisabled: isLockedAll || isDropZonesDisabled,
withPosition: true,
...dropEventHandlers,
} );
Expand Down
5 changes: 5 additions & 0 deletions packages/block-library/src/gallery/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
// Override the default list style type _only in the editor_
// to avoid :not() selector specificity issues.
// See https://github.com/WordPress/gutenberg/pull/10358

li {
list-style-type: none;
.components-drop-zone {
display: none;
pointer-events: none;
}
}

// @todo: this deserves a refactor, by being moved to the toolbar.
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/gallery/gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const Gallery = ( props ) => {
},
{
allowedBlocks: [ 'core/image' ],
dropZonesDisabled: true,
orientation: 'horizontal',
renderAppender: false,
__experimentalLayout: { type: 'default', alignments: [] },
Expand Down

0 comments on commit cc05d60

Please sign in to comment.