fix(sections): a section can hold more than one task
Reported as "sections can only have one task", and that is exactly what it looked like. TaskList read the dragged task from its own `draggingId`, which is only set when the drag *started* in that list. A task dragged in from the unsectioned rows above, or from another section, arrived as null and the handler returned early — after it had already called `stopPropagation`, so the section around it never got the drop either. So a section could only be dropped into while it was empty, because an empty one has no row in the way to swallow the drop. Put one task in and there was no route to a second. The id comes out of `dataTransfer` at drop time now, and `dragover` decides with `carries()` rather than local state — which is the only thing a target can read while a drag is in the air. The stuck frame was the same cause: the section's own cleanup never ran, so the highlight stayed lit after the drop. It is cleared on `dragend` now, which fires once per drag on the source and bubbles to the window — the one place that is true however a drag ends, including one abandoned with Escape, which produces no drop at all and left the frame standing too. The smoke test drops a second task onto the row already in the section, which is the gesture that did nothing, and runs in WebKit as well. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
6853897d00
commit
d6d5bf590b
@@ -197,6 +197,24 @@
|
||||
*/
|
||||
let overSection = $state(null);
|
||||
|
||||
/**
|
||||
* Clears the highlight when the drag ends, however it ends.
|
||||
*
|
||||
* `dragleave` and the section's own `ondrop` are not enough. A drop on a *row*
|
||||
* inside a section is handled by TaskList, which stops propagation — so the
|
||||
* section never sees the drop and its frame stayed lit afterwards. A drag
|
||||
* abandoned with Escape has the same shape: no drop at all, and the frame kept
|
||||
* standing until the next one.
|
||||
*
|
||||
* `dragend` fires exactly once per drag, on the source, and bubbles to the
|
||||
* window — so it is the one place that is true for every way a drag can finish.
|
||||
*/
|
||||
$effect(() => {
|
||||
const clear = () => (overSection = null);
|
||||
window.addEventListener('dragend', clear);
|
||||
return () => window.removeEventListener('dragend', clear);
|
||||
});
|
||||
|
||||
function onSectionDragOver(event, sectionId) {
|
||||
if (!canEdit || !carries(event, TASK)) return;
|
||||
accept(event);
|
||||
|
||||
Reference in New Issue
Block a user