question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FullCalendar shows events duplicated on modification

See original GitHub issue

Reduced Test Case

https://codesandbox.io/s/zealous-jepsen-190d2?file=/src/DemoApp.jsx

Bug Description

If I press down on an event, move it, release the mouse button, press the mouse button again, -> can drag a copy of the event

Screenshots

From the minimal working example event_duplication

In the app, with some more hooks/delay it works close to every time. The title is rendered as the title is calculated in eventDidMount duplication_from_app

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:19 (4 by maintainers)

github_iconTop GitHub Comments

7reactions
sebap100commented, Jan 28, 2021

when merging the new event into with the running events array, don’t just merge in an EventApi object, use EventApi::toPlainObject instead…

https://codesandbox.io/s/quirky-nightingale-vr1k1?file=/src/DemoApp.jsx

https://fullcalendar.io/docs/Event-toPlainObject

@arshaw I still have the issue with your solution (even in your codesandbox). Please, try to drag and drop an event into a different time slot and immediately after dropping the event, re-drag it (within the 2 seconds) to another time slot without dropping it, you will see that the event is still duplicated.

This issue occurs exactly when you are dragging an event, at the same time that a React setState occurs in the background (in this case in the setTimeout callback). This causes a render of the component. Thus, the events given to FullCalendar through the events props are displayed again.

When the render occurs, it is like the moving event is unsync with the initial dragging event when a render occurs during the move. Thus, when dropping, FullCalendar creates a broad new event.

5reactions
Herz3hcommented, Oct 27, 2020

Same issue on fullcalendar-vue 5.3.0

ezgif com-gif-maker

In my case, this code is used on every eventDrop:


        async onEventDrop(data)
        {
            var end = data.event.end;
            if(end == null)
            {
                end = dayjs(data.event.start).toDate();
            }

            this.changeDate(data.event, data.revert);
        },

        async changeDate(event, revert)
        {
            try
            {
                await $.post({
                    url: Routing.generate('calendar_changedate'),
                    data: {
                        id: event.id,
                        start: dayjs(event.start).format("YYYY-MM-DD HH:mm"),
                        end: dayjs(event.end).format("YYYY-MM-DD HH:mm"),
                        isAllDay: false
                    }
                });
            }
            catch(e)
            {
                revert()
            }
        },

Edit:

I also checked your react example @arshaw , and it still duplicates:

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

FullCalendar shows events duplicated on modification #7071
This issue occurs exactly when you are dragging an event, at the same time that a React setState occurs in the background (in...
Read more >
Events are duplicated when switching months in Fullcalendar v4
Events are loaded correctly, but when I manually add a new one (it is also saved to SQL database via ajax call), then...
Read more >
FullCalendar - Javascript Event Calendar - Duplicate Events
In agenda week/day view, when we use timely events (With allDay: false ) it is showing duplicate events in other days as well....
Read more >
How do I add and duplicate an event in the Calenda...
Once created in a course calendar, duplicate events are not linked together and are independent events. Therefore, if users need to modify an...
Read more >
Event Object - Docs | FullCalendar
String. Events that share a groupId will be dragged and resized together automatically. · Boolean ( true or false ). Determines if the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found