fix(shared-ui): block click event after drag to prevent detail view opening

After a successful drag-and-drop, the browser fires a click event on
the source element. This was opening the detail view overlay instead of
completing the drop. Now a one-time click blocker is added after drag
ends to swallow the spurious click.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Till JS 2026-04-03 13:15:53 +02:00
parent 9b8814ea37
commit a15b027e96

View file

@ -108,6 +108,15 @@ export function dragSource(node: HTMLElement, options: DragSourceOptions) {
})
);
endDrag();
// Block the click event that fires after pointerup — prevents
// opening detail views when dropping an item.
const blocker = (ev: Event) => {
ev.stopPropagation();
ev.preventDefault();
};
node.addEventListener('click', blocker, { capture: true, once: true });
// Safety: remove blocker after a tick in case click doesn't fire
setTimeout(() => node.removeEventListener('click', blocker, { capture: true }), 0);
}
cleanup();
}