fix(planner): let a timed booking stay where it is dropped when only other bookings stand against its time

A booking dropped against another booking's time went back to the nearest
slot its own time allowed. With a 06:30 flight listed below the day's
untimed stops, every slot among them was against the flight, so a 13:00
transit dropped between two stops went back behind the flight on every
drop, and the flight's legs cannot be dragged out of the way.

The dropped row now stays where it was dropped and the other timed
bookings it puts out of order move next to it, the earlier ones ahead of
it and the later ones behind. Timed stops and notes never move: against
one of those the row is still seated by its time as before (#2631). The
phone's move applies the same rule before it refuses a move.

Closes #2983
This commit is contained in:
Maurice
2026-11-05 12:15:53 +01:00
parent 14c767a675
commit 91630dd811
4 changed files with 151 additions and 16 deletions
@@ -7,7 +7,7 @@ import { toDisplayTemp } from '../../../../components/Planner/dayDetailModel'
import { getDayBookendHotels } from '../../../../utils/dayOrder'
import { dayWeatherAnchor } from '../../../../utils/dayWeather'
import { metadataWithLegPositions, planMergedOrder, withTransportPositions } from '../../../../utils/mergedOrder'
import { getDisplayTimeForDay, getMergedItems, getTransportForDay, hasCarrierEndpointOnDay, isCarrierTransport, stopDayIds } from '../../../../utils/dayMerge'
import { getDisplayTimeForDay, getMergedItems, getTransportForDay, hasCarrierEndpointOnDay, isCarrierTransport, stopDayIds, yieldTimedBookings } from '../../../../utils/dayMerge'
import { dayCoMapsUrl, dayExportStops, dayGoogleMapsUrl, optimizeDayOrder, type DayCarrier } from '../../../../components/Planner/dayRoute'
import type { PlannedTransitLeg, TransitLeg } from '../../../../components/Planner/transitLeg'
import { useTransitLegPlanner } from '../../../../components/Planner/useTransitLegPlanner'
@@ -208,10 +208,17 @@ export function useMPlanTimeline(planner: TripPlanner) {
const newOrder = [...merged]
newOrder.splice(idx, 1)
newOrder.splice(toIndex, 0, item)
// Same guard as the desktop arrow buttons: a TIMED item may not jump past
// other timed items (untimed items move freely and keep their neighbours).
// A TIMED item may not jump past other timed items (untimed items move freely and
// keep their neighbours). Bookings it passes make room when they can, as on a desktop
// drop (#2983); a timed stop or note in the way, or a move that leaves the day as it
// was, is refused.
if (itemHasTime(item, day.id) && breaksChronology(newOrder, day.id, getDisplayTimeForDay)) {
toast.info(t('dayplan.cannotBreakChronology'))
const yielded = yieldTimedBookings(newOrder, toIndex, day.id, getDisplayTimeForDay)
if (!yielded || yielded.every((it, i) => it === merged[i])) {
toast.info(t('dayplan.cannotBreakChronology'))
return
}
void applyMergedOrder(day.id, yielded)
return
}
void applyMergedOrder(day.id, newOrder)