Skip to content

Conversation

@AbiT-246
Copy link

@AbiT-246 AbiT-246 commented Dec 28, 2025

This PR improves event rendering in the day view by positioning and sizing events proportionally based on their actual start and end times within each day, instead of spanning the full day cell.
Fixes #223

Changes

Proportional positioning for single-day events

  • Calculates the event’s offset from the start of the day in minutes
  • Computes the event duration in minutes
  • Converts these to percentages to position the event within the day cell
  • Positions events at their actual start time

Proportional sizing

  • Event width reflects the actual duration
  • Uses percentage-based calculations to ensure accurate visual representation
  • Includes a minimum width of 1px to maintain visibility

Multi-day event handling

  • For multi-day events, calculates proportions relative to the total span
  • Handles the first day of multi-day events with proportional positioning
  • Maintains accurate visual representation across day boundaries

Summary by CodeRabbit

  • New Features

    • Added Day-level rendering adjustments for more accurate multi-day and single-day display.
    • Introduced drag-and-drop wiring for resource event lists to enable DnD interactions.
  • Bug Fixes

    • Improved event positioning and sizing in day-level calendar views.
    • Ensured single-day events render with accurate proportional offsets and a minimum visible width.
    • Fixed multi-day event rendering so first-day and subsequent-day portions display consistently.
    • Stabilized rendering keys to reduce visual glitches and re-render issues.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link

vercel bot commented Dec 28, 2025

@AbiT-246 is attempting to deploy a commit to the Ansul Agrawal's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

This comment was marked as outdated.

@AbiT-246 AbiT-246 changed the title Render events relative to their times Feat: Render events relative to their times Dec 28, 2025
coderabbitai[bot]

This comment was marked as outdated.

@ansulagrawal
Copy link
Owner

@AbiT-246, can you update the pr

coderabbitai[bot]

This comment was marked as outdated.

@ansulagrawal
Copy link
Owner

@AbiT-246, please resolve the conflict. I will push to the beta version.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In @src/components/ResourceEvents.jsx:
- Line 364: The key generation using `${evt.eventItem.id}_${headerItem.time}`
can collide when evt.eventItem.id is null/undefined or not stable; update the
key expression to use a stable fallback and include additional stable context
such as the enclosing resource id or the map index: e.g., build the key from
(evt.eventItem?.id ?? evt.id ?? `evt_${index}`) + '_' + (resource?.id ??
`res_${resourceIndex}`) + '_' + headerItem.time, ensuring you reference the same
variables used in the map (evt, eventItem, headerItem, resource, index) so the
key is always a non-empty unique string even when eventItem.id is missing.
- Around line 316-359: Replace the fixed 1440 and unclamped math: compute
dayDurationMinutes from the actual day bounds (e.g.,
dayStart.endOf('day').diff(dayStart.startOf('day'),'minute')) to handle DST,
clamp startOffsetMinutes and eventDurationMinutes into [0, dayDurationMinutes],
and use baseCellWidth consistently for leftOffset and totalWidth calculations so
padding/margin is honored for both single-day and multi-day (first-day)
branches; ensure width is Math.max(1, Math.min(computedWidth, totalWidth)) and
left is clamped so the rendered left+width cannot overflow the cell region
(apply to the CellUnit.Day branch where evt.span === 1 and the multi-day
isFirstDay branch, referencing variables dayDurationMinutes, baseCellWidth,
leftOffset, totalWidth, eventWidth, startPercentage, durationPercentage).
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 72753ea and 0d256ce.

📒 Files selected for processing (1)
  • src/components/ResourceEvents.jsx
🔇 Additional comments (1)
src/components/ResourceEvents.jsx (1)

434-469: The wrapper is correctly implemented; the raised concerns are largely unfounded.

1) Default export change: Not a breaking change. ResourceEvents is not part of the public API (src/index.js only exports Scheduler, SchedulerData, etc.); only index.jsx internally imports it.

2) Missing item parameter: Correct as-is. The spec functions expect signature (props, monitor, component), not (item, ...). When handlers need the dragged item, they call monitor.getItem() directly (see DnDContext.js line 71 in hover). The wrapper correctly delegates to spec with (props, monitor, componentRef.current).

3) Empty accept: []: Supported and correct. Per react-dnd API, empty accept disables drops as intended for the disabled path.

4) Ref type (componentRef.current): Correct. The wrapper passes the class instance, which has the eventContainer property that spec.drop/hover expect (DnDContext.js line 29 accesses component.eventContainer).

Likely an incorrect or invalid review comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Partial Time Blocks in week view

3 participants