From d3f1fadc2cb2111d6d5202bdef24a6ccdaa65576 Mon Sep 17 00:00:00 2001 From: Maurice Date: Mon, 25 May 2026 00:59:28 +0200 Subject: [PATCH] fix(plan): allow dropping a new place onto a day note The note drop handler had no branch for a place dragged in from the places sidebar, so dropping a new activity onto a note (e.g. to place it just above the note) did nothing. Handle the place id and insert it among the assignments at the note's position. Closes #967 --- client/src/components/Planner/DayPlanSidebar.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/client/src/components/Planner/DayPlanSidebar.tsx b/client/src/components/Planner/DayPlanSidebar.tsx index 57c9bc87..7e2d9f2f 100644 --- a/client/src/components/Planner/DayPlanSidebar.tsx +++ b/client/src/components/Planner/DayPlanSidebar.tsx @@ -1786,8 +1786,17 @@ const DayPlanSidebar = React.memo(function DayPlanSidebar({ onDragOver={e => { e.preventDefault(); e.stopPropagation(); if (dropTargetKey !== `note-${note.id}`) setDropTargetKey(`note-${note.id}`) }} onDrop={e => { e.preventDefault(); e.stopPropagation() - const { noteId: fromNoteId, assignmentId: fromAssignmentId, reservationId: fromReservationId, fromDayId, phase } = getDragData(e) - if (fromReservationId && fromDayId !== day.id) { + const { placeId, noteId: fromNoteId, assignmentId: fromAssignmentId, reservationId: fromReservationId, fromDayId, phase } = getDragData(e) + if (placeId) { + // New place dropped onto a note: insert it among the + // assignments at the note's position (after the places + // above it), so it lands right where the note sits. + const tm = getMergedItems(day.id) + const noteIdx = tm.findIndex(i => i.type === 'note' && i.data.id === note.id) + const pos = tm.slice(0, noteIdx).filter(i => i.type === 'place').length + onAssignToDay?.(parseInt(placeId), day.id, pos) + setDropTargetKey(null); window.__dragData = null + } else if (fromReservationId && fromDayId !== day.id) { const r = reservations.find(x => x.id === Number(fromReservationId)) if (r) { const update = computeMultiDayMove(r, day.id, phase); tripActions.updateReservation(tripId, r.id, update).catch((err: unknown) => toast.error(err instanceof Error ? err.message : t('common.unknownError'))) } setDraggingId(null); setDropTargetKey(null); dragDataRef.current = null