Skip to content

Conversation

@TirlaP
Copy link
Contributor

@TirlaP TirlaP commented May 5, 2025

Issue
When dragging items from outside sources into the calendar and dropping them, ghost preview elements sometimes remain visible after the drop operation completes. This creates a confusing UI where users see duplicate events - both the actual placed event and a lingering preview.

Solution
This PR adds a minimal fix by:

  1. Adding a _cleanupPreviewElements helper method to the EventContainerWrapper component
  2. Calling this method only in the handleDropFromOutside function
  3. Directly removing any .rbc-addons-dnd-drag-preview elements from the DOM after an outside drop completes

The changes are intentionally minimal, only addressing the specific case of ghost previews after dropping from outside sources, without modifying any other component behaviors.

Testing
Tested with various drag operations from outside sources:

  • Dragging items from outside into different time slots
  • Performing consecutive drag operations from outside
  • Confirming no ghost previews remain after dropping

The fix successfully cleans up preview elements without any side effects on normal drag and drop functionality.

This is the photo with the problem on my app, problem that happens as well in the library, but you can't actually see it because the events are coloured in the same way.

Screenshot 2025-05-05 at 16 43 38

Screenshot 2025-05-05 at 16 45 51
Screenshot 2025-05-05 at 16 46 22

@TirlaP
Copy link
Contributor Author

TirlaP commented May 5, 2025

@cutterbl Aloha :D,

When you have time, could you take a look at this PR, please?
It's a bug that it's happening in my app, I tried to hide the.rbc-addons-dnd-drag-preview className by display: none !important;

But this didn't work so I have created a PR to solve this thing. I have put a thorough description for it, but for any other questions you might have, let me know.

Thanks!

@cutterbl cutterbl merged commit 652502f into jquense:master May 28, 2025
1 check passed
github-actions bot pushed a commit that referenced this pull request May 28, 2025
# [1.19.0](v1.18.0...v1.19.0) (2025-05-28)

### Bug Fixes

* Clean up preview elements after dropping from outside ([#2746](#2746)) ([652502f](652502f))
* issue [#2534](#2534) ([#2566](#2566)) ([10cfe84](10cfe84))

### Features

* **time-indicator-wrapper:** expose time indicator wrapper component ([#2747](#2747)) ([10b8041](10b8041))
@github-actions
Copy link

🎉 This PR is included in version 1.19.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@TirlaP TirlaP mentioned this pull request May 28, 2025
@j0nas
Copy link

j0nas commented Jun 15, 2025

Events that are dropped into the "all day" slot of a day seem to still not be cleared.

I add the following code to my handleDropFromOutside to work around this for now:

      // HACK: Workaround for a bug in react-big-calendar where the drag
      // preview element is not always cleaned up after dropping an external event,
      // particularly on all-day slots.
      // We manually remove the preview element after a short delay.
      // Ref: https://github.com/jquense/react-big-calendar/pull/2746
      setTimeout(() => {
        document
          .querySelectorAll('.rbc-addons-dnd-drag-preview')
          ?.forEach((node) => node.remove());
      }, 0);
    },
    [assignmentEvent, openModalForAssignmentEvent],
  );

leonpro00 added a commit to leonpro00/react-calendar that referenced this pull request Sep 17, 2025
# [1.19.0](jquense/react-big-calendar@v1.18.0...v1.19.0) (2025-05-28)

### Bug Fixes

* Clean up preview elements after dropping from outside ([#2746](jquense/react-big-calendar#2746)) ([652502f](jquense/react-big-calendar@652502f))
* issue [#2534](jquense/react-big-calendar#2534) ([#2566](jquense/react-big-calendar#2566)) ([10cfe84](jquense/react-big-calendar@10cfe84))

### Features

* **time-indicator-wrapper:** expose time indicator wrapper component ([#2747](jquense/react-big-calendar#2747)) ([10b8041](jquense/react-big-calendar@10b8041))
github-actions bot pushed a commit to additio/react-big-calendar that referenced this pull request Oct 15, 2025
# [1.3.0](v1.2.0...v1.3.0) (2025-10-15)

### Bug Fixes

* add appearance: button for better cross-browser button styling c… ([jquense#2677](https://github.com/additio/react-big-calendar/issues/2677)) ([85be249](85be249)), closes [jquense#2676](https://github.com/additio/react-big-calendar/issues/2676)
* Clean up preview elements after dropping from outside ([jquense#2746](https://github.com/additio/react-big-calendar/issues/2746)) ([652502f](652502f))
* correctly show +more buttons on slots with hidden spanning events ([jquense#2744](https://github.com/additio/react-big-calendar/issues/2744)) ([dbd0b0a](dbd0b0a))
* Customize drag from outside event's length ([jquense#2681](https://github.com/additio/react-big-calendar/issues/2681)) ([2ed9465](2ed9465)), closes [jquense#2680](https://github.com/additio/react-big-calendar/issues/2680)
* **dayjs localizer:** reverts previous changs, as it was casting a date as UTC instead of local time ([jquense#2759](https://github.com/additio/react-big-calendar/issues/2759)) ([7ba9e24](7ba9e24)), closes [jquense#2758](https://github.com/additio/react-big-calendar/issues/2758)
* **dnd:** added check for null dragFromOutsideItem, updated example ([jquense#2651](https://github.com/additio/react-big-calendar/issues/2651)) ([17e62a3](17e62a3)), closes [jquense#2616](https://github.com/additio/react-big-calendar/issues/2616) [jquense#2383](https://github.com/additio/react-big-calendar/issues/2383)
* fix dayjs localizer merge function to not change min and max upon tz change ([jquense#2712](https://github.com/additio/react-big-calendar/issues/2712)) ([7d2aa77](7d2aa77))
* issue [jquense#2534](https://github.com/additio/react-big-calendar/issues/2534) ([jquense#2566](https://github.com/additio/react-big-calendar/issues/2566)) ([10cfe84](10cfe84))
* Replaces createFactory with createElement ([jquense#2754](https://github.com/additio/react-big-calendar/issues/2754)) ([23a0fae](23a0fae)), closes [jquense#2377](https://github.com/additio/react-big-calendar/issues/2377) [jquense#1831](https://github.com/additio/react-big-calendar/issues/1831) [jquense#2740](https://github.com/additio/react-big-calendar/issues/2740)
* **Toolbar:** cursor styling on hover ([jquense#2700](https://github.com/additio/react-big-calendar/issues/2700)) ([7029eb3](7029eb3)), closes [jquense#2697](https://github.com/additio/react-big-calendar/issues/2697)
* update doc type of onDropFromOutside function signature ([5438fb5](5438fb5))
* Update Slack channel invite in README.md ([47dadc3](47dadc3))
* Update Slack channel invite link in README-ar.md ([de8dd0f](de8dd0f))

### Features

* add support for React 19 ([jquense#2710](https://github.com/additio/react-big-calendar/issues/2710)) ([4d39499](4d39499))
* adds a new event id accessor ([jquense#2693](https://github.com/additio/react-big-calendar/issues/2693)) ([9883ace](9883ace))
* **components:** showMore component customization ([jquense#2537](https://github.com/additio/react-big-calendar/issues/2537)) ([afb3138](afb3138)), closes [jquense#2391](https://github.com/additio/react-big-calendar/issues/2391)
* **dayPropGetter:** pass resourceId to method ([jquense#2650](https://github.com/additio/react-big-calendar/issues/2650)) ([272eb88](272eb88)), closes [jquense#2634](https://github.com/additio/react-big-calendar/issues/2634)
* implement Conditional Resource Grouping ([jquense#2679](https://github.com/additio/react-big-calendar/issues/2679)) ([d52f836](d52f836))
* **time-indicator-wrapper:** expose time indicator wrapper component ([jquense#2747](https://github.com/additio/react-big-calendar/issues/2747)) ([10b8041](10b8041))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants