Skip to content

Commit

Permalink
fix: dropping node into empty container: (#563)
Browse files Browse the repository at this point in the history
Resolve issue where a node was not able to be placed within a container using the layers drag and drop interface when the accepting container had no children
  • Loading branch information
brendanowens authored Sep 30, 2023
1 parent 6106115 commit 126532e
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions packages/layers/src/events/LayerHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,7 @@ export class LayerHandlers extends DerivedCoreEventHandlers<{

const { indicator, currentCanvasHovered } = LayerHandlers.events;

if (
currentCanvasHovered &&
indicator &&
currentCanvasHovered.data.nodes
) {
if (currentCanvasHovered && indicator) {
const heading = this.getLayer(
currentCanvasHovered.id
).headingDom.getBoundingClientRect();
Expand All @@ -70,6 +66,17 @@ export class LayerHandlers extends DerivedCoreEventHandlers<{
];

if (!currNode) {
// If the currentCanvasHovered has no child nodes, then we place the indicator as the first child
LayerHandlers.events.indicator = {
...indicator,
placement: {
...indicator.placement,
index: 0,
where: 'before',
parent: currentCanvasHovered,
},
onCanvas: true,
};
return;
}

Expand Down

0 comments on commit 126532e

Please sign in to comment.