Skip to content

Commit

Permalink
Fix drag and drop into the Columns block (#20822)
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad authored Mar 12, 2020
1 parent 07d751a commit e41535d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
3 changes: 3 additions & 0 deletions packages/components/src/drop-zone/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export function useDropZone( {
onDrop,
isDisabled,
withPosition,
__unstableIsRelative = false,
} ) {
const { addDropZone, removeDropZone } = useContext( Context );
const [ state, setState ] = useState( {
Expand All @@ -39,6 +40,7 @@ export function useDropZone( {
onHTMLDrop,
setState,
withPosition,
isRelative: __unstableIsRelative,
};
addDropZone( dropZone );
return () => {
Expand Down Expand Up @@ -76,6 +78,7 @@ function DropZoneComponent( {
onFilesDrop,
onHTMLDrop,
onDrop,
__unstableIsRelative: true,
}
);

Expand Down
24 changes: 12 additions & 12 deletions packages/components/src/drop-zone/provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,18 @@ class DropZoneProvider extends Component {
);

// Find the leaf dropzone not containing another dropzone
const hoveredDropZone = find(
hoveredDropZones,
( zone ) =>
! some(
hoveredDropZones,
( subZone ) =>
subZone !== zone &&
zone.element.current.parentElement.contains(
subZone.element.current
)
)
);
const hoveredDropZone = find( hoveredDropZones, ( zone ) => {
const container = zone.isRelative
? zone.element.current.parentElement
: zone.element.current;

return ! some(
hoveredDropZones,
( subZone ) =>
subZone !== zone &&
container.contains( subZone.element.current )
);
} );

const hoveredDropZoneIndex = this.dropZones.indexOf( hoveredDropZone );

Expand Down

0 comments on commit e41535d

Please sign in to comment.