@@ -42,6 +42,7 @@ export const WeekInteractionCoordinator: FC<Props> = ({
4242 } ) ;
4343 const { actions, confirmation, setters, state } = useDraftContext ( ) ;
4444 const mutations = useEventMutations ( ) ;
45+ const activeInteractionEventRef = useRef < Event | null > ( null ) ;
4546 const layoutSourcesRef = useRef ( getLayoutSources ) ;
4647 const timedEventsById = useMemo ( ( ) => {
4748 return mapEventsById ( timedEvents ) ;
@@ -96,7 +97,13 @@ export const WeekInteractionCoordinator: FC<Props> = ({
9697 // draft from the query cache's source Event plus the engine's resulting
9798 // dates.
9899 const gridEventDraftFromSavedResult = ( event : GridEvent ) => {
99- const sourceEvent = event . _id ? eventsById . get ( event . _id ) : undefined ;
100+ const sourceEvent = event . _id
101+ ? resolveInteractionSourceEvent (
102+ event . _id ,
103+ eventsById ,
104+ activeInteractionEventRef . current ,
105+ )
106+ : undefined ;
100107 const draft = sourceEvent ? editGridEventDraft ( sourceEvent , "this" ) : null ;
101108
102109 if ( ! draft ) return null ;
@@ -176,6 +183,13 @@ export const WeekInteractionCoordinator: FC<Props> = ({
176183 onCommitTimedDrag : commitSavedMutation ,
177184 onCommitTimedResize : commitSavedMutation ,
178185 onMotionActivation : ( target ) => {
186+ // Edge navigation replaces the visible query before pointer-up. Retain
187+ // the canonical source so the destination-week commit can still build
188+ // its strict mutation input.
189+ activeInteractionEventRef . current = target . event . _id
190+ ? ( eventsById . get ( target . event . _id ) ?? null )
191+ : null ;
192+
179193 if ( target . hadFormOpenBeforeInteraction ) {
180194 actions . closeForm ( ) ;
181195 }
@@ -208,3 +222,11 @@ const mapEventsById = (events: GridEvent[]) => {
208222
209223 return eventsById ;
210224} ;
225+
226+ export const resolveInteractionSourceEvent = (
227+ eventId : string ,
228+ visibleEventsById : ReadonlyMap < string , Event > ,
229+ activeInteractionEvent : Event | null ,
230+ ) =>
231+ visibleEventsById . get ( eventId ) ??
232+ ( activeInteractionEvent ?. id === eventId ? activeInteractionEvent : undefined ) ;
0 commit comments