-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Clean up preview elements after dropping from outside #2746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean up preview elements after dropping from outside #2746
Conversation
|
@cutterbl Aloha :D, When you have time, could you take a look at this PR, please? 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! |
# [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))
|
🎉 This PR is included in version 1.19.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
|
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 // 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],
); |
# [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))
# [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))
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:
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:
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.