Skip to content

🐛 fix(duplicate-event): fix event duplication - web#1001

Merged
victor-enogwe merged 2 commits intomainfrom
fix-duplicate-events-995-web
Sep 26, 2025
Merged

🐛 fix(duplicate-event): fix event duplication - web#1001
victor-enogwe merged 2 commits intomainfrom
fix-duplicate-events-995-web

Conversation

@victor-enogwe
Copy link
Contributor

What does this PR do?

Web fix

The duplicate functionality was completely broken for both calendar and someday events. When users attempted to duplicate an event via right-click context menu or the Meta+D keyboard shortcut, no new event was created and the UI did not update. This regression was introduced in commit 2de11df during the recent refactoring of draft actions.

Root Cause

The duplicateEvent function in useDraftActions.ts was incorrectly passing the original event's _id to the submit function:

const duplicateEvent = useCallback(() => {
  const draft = MapEvent.removeProviderData({
    ...reduxDraft,
  }) as Schema_GridEvent;

  submit(draft); // ❌ This includes the original _id
  discard();
}, [reduxDraft, submit, discard]);

When an event has an existing _id, the submit function treats it as an edit operation rather than a create operation, causing the duplicate to overwrite the original event instead of creating a new one.

Copilot AI review requested due to automatic review settings September 26, 2025 09:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a critical bug in the event duplication functionality for the web application. The issue was that when users attempted to duplicate events through right-click context menu or Meta+D shortcut, no new event was created because the duplicate function was passing the original event's _id, causing the system to treat it as an edit operation instead of a create operation.

  • Fixes the duplicateEvent function to properly generate optimistic IDs for new events
  • Updates type definitions to use more specific Schema_WebEvent types instead of generic Schema_Event
  • Adds proper type safety and validation improvements across event handling utilities

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
useDraftActions.ts Core fix: Uses replaceIdWithOptimisticId in duplicate function and improves type safety
event.types.ts Updates type definitions to use Schema_WebEvent instead of Schema_OptimisticEvent
grid.event.validator.test.ts Adds missing position properties to test fixtures for proper validation
web.date.util.ts Removes unused recurrence-related imports and functions
event.util.ts Improves type safety and validation in event preparation utilities
web.event.types.ts Consolidates type definitions and removes unused recurrence enum
event.types.ts Simplifies recurrence schema definitions by removing redundant omit/extend patterns
map.event.ts Improves recurrence handling in the removeProviderData function

@victor-enogwe victor-enogwe merged commit 37816a3 into main Sep 26, 2025
4 checks passed
@victor-enogwe victor-enogwe deleted the fix-duplicate-events-995-web branch September 26, 2025 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants