Skip to content

Commit 5ffd4f4

Browse files
authored
fix(web): keep day event form closed after drag (#1888)
* docs(web): define day drag form lifecycle * docs(web): plan day drag form lifecycle * test(web): cover day drag form lifecycle * fix(web): keep day event form closed after drag * chore: keep agent planning docs local * chore: remove unnecessary test
1 parent 9800591 commit 5ffd4f4

3 files changed

Lines changed: 32 additions & 14 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ node_modules/
3939
playwright-report/
4040
test-results/
4141
blob-report/
42+
# Local agent-generated plans and specs
4243
docs/superpowers/
4344
docs/pr-explainers/
4445

packages/web/src/views/Day/interaction/DayInteractionCoordinator.test.tsx

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,10 @@ describe("DayInteractionCoordinator", () => {
204204
expect(isOpenAtCursor(CursorItem.EventForm)).toBe(false);
205205
});
206206

207-
it("reopens the Day event form with the moved event instead of immediately saving", async () => {
207+
it("saves a moved event without opening a form", async () => {
208208
const { dispatch, store } = renderCoordinator();
209-
const source = screen.getByTestId("timed-source");
210209
const child = screen.getByTestId("timed-child");
211210

212-
openFloatingForm(source);
213211
fireEvent.pointerDown(child, {
214212
button: 0,
215213
clientX: 160,
@@ -229,15 +227,37 @@ describe("DayInteractionCoordinator", () => {
229227
pointerId: 1,
230228
});
231229

232-
expect(
233-
dispatch.mock.calls.some(
234-
([action]) => action.type === editEventSlice.actions.request.type,
235-
),
236-
).toBe(false);
230+
await waitFor(() => {
231+
expect(
232+
dispatch.mock.calls.some(
233+
([action]) => action.type === editEventSlice.actions.request.type,
234+
),
235+
).toBe(true);
236+
});
237+
expect(isOpenAtCursor(CursorItem.EventForm)).toBe(false);
238+
expect(store.getState().events.draft.event).toBeNull();
239+
});
240+
241+
it("opens the event form when pointer interaction does not move the event", async () => {
242+
const { store } = renderCoordinator();
243+
const child = screen.getByTestId("timed-child");
244+
245+
fireEvent.pointerDown(child, {
246+
button: 0,
247+
clientX: 160,
248+
clientY: 160,
249+
isPrimary: true,
250+
pointerId: 1,
251+
});
252+
fireEvent.pointerUp(window, {
253+
clientX: 160,
254+
clientY: 160,
255+
pointerId: 1,
256+
});
237257

238258
await waitFor(() => {
239259
expect(isOpenAtCursor(CursorItem.EventForm)).toBe(true);
240-
expect(store.getState().events.draft.event?.startDate).toContain("10:00");
241260
});
261+
expect(store.getState().events.draft.event?._id).toBe(timedEvent._id);
242262
});
243263
});

packages/web/src/views/Day/interaction/DayInteractionCoordinator.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,9 @@ export const DayInteractionCoordinator: FC<Props> = ({
115115
return;
116116
}
117117

118-
if (result.hadFormOpenBeforeInteraction) {
119-
openDayCalendarEvent(result.event);
120-
return;
121-
}
122-
118+
closeFloatingAtCursor();
123119
updateEvent({ event: result.event }, true);
120+
dispatch(draftSlice.actions.discard(undefined));
124121
};
125122

126123
runtimeRef.current = {

0 commit comments

Comments
 (0)