Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/angular/tests/adapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,9 @@ describe('@dndgem/angular integration', () => {
host.mechanics!.drop('chart', { x: 20, y: 10 });
await flush(fixture);
expect(tags).toEqual(['B']);
expect(host.mechanics!.connectCount()).toBe(connectsAfterMount);
// Accepted drop remasures + reconnects mechanics so the next drag baseline
// matches applied geometry (DND-BUG-DRAG-INTENT-1). Callback flips must not.
expect(host.mechanics!.connectCount()).toBe(connectsAfterMount + 1);
});

it('matches createLayoutSession ResolvedLayout for the same normalized inputs', async () => {
Expand Down
24 changes: 24 additions & 0 deletions packages/dom/src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,26 @@ export function createLayoutSession(input: LayoutSessionInput): LayoutSession {
});
};

/**
* After committed geometry is written to the DOM, left/top changes do not
* notify ResizeObserver. Remeasure and reconnect so the next drag start
* baseline matches applied positions (DND-BUG-DRAG-INTENT-1). Also refreshes
* interaction authority to the session commit (Auto-Layout recompose).
*/
const syncInteractionAfterApply = (): void => {
if (disposed || reconnecting) {
return;
}
const snapshot = measureLayout({
container: input.container,
items: elements,
});
// Seed lastSnapshot before reconnect so observeLayout's initial emit is a
// duplicate and handleMeasure does not idle-re-solve the just-committed layout.
lastSnapshot = snapshot;
connectInteraction();
};

const applyPreview = (proposal: DragProposal): void => {
const previewLayout = proposal.preview.resolved;
applyLayoutPlacements({
Expand Down Expand Up @@ -574,6 +594,9 @@ export function createLayoutSession(input: LayoutSessionInput): LayoutSession {
} else {
applyCommitted();
}
// Drop (accept or reject) always ends with applied committed geometry.
// Refresh measurement + interaction before the next drag (DND-BUG-DRAG-INTENT-1).
syncInteractionAfterApply();
onDrop?.(event);
emit();
},
Expand All @@ -582,6 +605,7 @@ export function createLayoutSession(input: LayoutSessionInput): LayoutSession {
return;
}
applyCommitted();
syncInteractionAfterApply();
onCancel?.(event);
emit();
},
Expand Down
Loading
Loading