Skip to content

Item collision event#898

Open
terox wants to merge 8 commits intonamespace-ee:mainfrom
terox:item-collision-event
Open

Item collision event#898
terox wants to merge 8 commits intonamespace-ee:mainfrom
terox:item-collision-event

Conversation

@terox
Copy link

@terox terox commented Feb 5, 2023

Issue Number

#523

Overview of PR

We added the functionality to detect collision between items in the same group.

Now you can detect collisions doing:

export default function Timetable() {
  const handleItemCollision = (currentItem, item) => {
    console.log('Item ' + currentItem.id + 'collided with ' + item.id)
  }

  return (
    <Timeline onCollision={this.handleItemCollision} />
  );
}

Authors of commit @GabrielCrackPro @albertoncp @terox

@lnagel
Copy link
Member

lnagel commented Feb 5, 2026

@developer-ocansey — Flagging this for your review.

Recommendation: Concept worth adopting, but implementation needs rework

What it does

Adds an onCollision callback prop that fires after an item is moved or resized, detecting if it overlaps with other items in the same group based on time ranges. Linked to issue #523.

Why it's valuable

Item collision detection is a useful feature for scheduling applications. Knowing when items overlap after a drag/resize lets consumers enforce constraints, show warnings, or auto-resolve conflicts.

Issues with the current implementation

  1. Bug — ID vs index mismatch: isCollision takes pickedItem as an array index, but dropItem passes the item ID. These are not the same thing.
  2. Ignores the keys system: Uses hardcoded start, end, group property names instead of the library's configurable keys prop (e.g., itemTimeStartKey, itemTimeEndKey).
  3. Duplicates existing logic: The library already has a collision function in calendar.tsx that handles 2D collision detection properly — this PR reimplements a simpler version from scratch.
  4. Targets old JS files: Timeline.js and utility/generic.js are now .tsx/.ts.

Suggested approach for a fresh implementation

  • Use the existing collision function from calendar.tsx (or a variant of it) rather than a separate isCollision utility
  • Respect the keys system for property access
  • Fire the callback from dropItem and resizedItem in Timeline.tsx with proper item data (not array indices)
  • Add tests

Effort estimate

Medium — the concept is straightforward but should be built on the existing collision infrastructure rather than ported from this PR.

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.

4 participants