Skip to content

fix(weekly-view): correct slot offset, zero topOffset positioning, and negative clamp#29420

Open
ManthanNimodiya wants to merge 2 commits into
calcom:mainfrom
ManthanNimodiya:fix/weekly-view-slot-offset
Open

fix(weekly-view): correct slot offset, zero topOffset positioning, and negative clamp#29420
ManthanNimodiya wants to merge 2 commits into
calcom:mainfrom
ManthanNimodiya:fix/weekly-view-slot-offset

Conversation

@ManthanNimodiya
Copy link
Copy Markdown

What does this PR do?

Fixes two rendering bugs in the weekly view causing time slot misalignment and content clipping (fixes #14208).

Bug 1: Wrong marginTop on first render
SchedulerColumns used offsetHeight || "var(--gridDefaultSize)" as marginTop. On first render the ref is unmeasured (undefined), so the fallback fires. But --gridDefaultSize is overridden inline to 58px (hourSize) while the actual spacer element is 28px (--calendar-offset-top). The 30px gap shifts the entire slot grid down — slots don't align with hour labels.

Bug 2: Slots at startHour:00 lose position: absolute
When a slot falls at exactly the start of the hour, topOffsetMinutes === 0. Truthy checks (topOffsetMinutes && "absolute" and topOffsetMinutes ? ... : undefined) treated 0 as "no offset", stripping absolute positioning from those slots.

Bug 3: Negative topOffsetMinutes clips slots above the viewport
In timezones behind UTC, a slot's converted local time can fall before startHour, making topOffsetMinutes negative and pushing slots above the visible grid.

Visual Demo (For contributors especially)

Beforemargin-top: 58px: slot grid is pushed 30px below the hour labels. The available slot on THU starts below the 9:00am line with a hatched gap above it.
Screenshot 2026-05-21 at 00 48 28
Screenshot 2026-05-21 at 00 48 28 (2)

Aftermargin-top: 28px: slot grid aligns flush with hour labels. The 9:00am slot starts exactly at the 9:00am line.
Screenshot 2026-05-21 at 00 49 09
Screenshot 2026-05-21 at 00 49 09 (2)

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs if this PR makes changes that would require a documentation change. N/A
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  1. Go to any booker page → switch to Weekly view
  2. Open DevTools → find <ol class="scheduler-grid-row-template"> → confirm margin-top is 28px not 58px
  3. Hover over the first slot at the top of any available hour (e.g. 9:00am) — it should highlight and be clickable
  4. Set system timezone to America/Los_Angeles (UTC-7) and reload — slots should stay within the grid, not clip above it

Checklist

  • My PR is small (2 files, 4 lines changed) and scoped to the reported bug

@github-actions
Copy link
Copy Markdown
Contributor

Welcome to Cal.diy, @ManthanNimodiya! Thanks for opening this pull request.

A few things to keep in mind:

  • This is Cal.diy, not Cal.com. Cal.diy is a community-driven, fully open-source fork of Cal.com licensed under MIT. Your changes here will be part of Cal.diy — they will not be deployed to the Cal.com production app.
  • Please review our Contributing Guidelines if you haven't already.
  • Make sure your PR title follows the Conventional Commits format.

A maintainer will review your PR soon. Thanks for contributing!

@github-actions github-actions Bot added booking-page area: booking page, public booking page, booker Medium priority Created by Linear-GitHub Sync ui area: UI, frontend, button, form, input 🐛 bug Something isn't working 🙋🏻‍♂️help wanted Help from the community is appreciated labels May 20, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 20, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1cc75e85-86ea-4ac2-8fb3-c5a1fed0ad42

📥 Commits

Reviewing files that changed from the base of the PR and between b6cde9a and e1233d0.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (3)
  • apps/web/modules/calendars/weeklyview/components/event/Empty.tsx
  • apps/web/modules/calendars/weeklyview/components/grid/index.tsx
  • apps/web/package.json
🚧 Files skipped from review as they are similar to previous changes (3)
  • apps/web/modules/calendars/weeklyview/components/grid/index.tsx
  • apps/web/package.json
  • apps/web/modules/calendars/weeklyview/components/event/Empty.tsx

📝 Walkthrough

Walkthrough

This PR fixes vertical positioning behavior in the weekly calendar view when offset values are zero or negative. The changes replace JavaScript truthy checks with explicit undefined checks to correctly treat zero as a valid offset value rather than a fallback condition. Empty-slot calculations clamp negative offsets to zero, and both Cell and CustomCell components now apply absolute positioning only when topOffsetMinutes is defined. The grid column's marginTop calculation switches to nullish coalescing for consistent zero-value handling. A minor dependency update bumps @radix-ui/react-tooltip to version 1.1.8.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically summarizes the main changes: fixing slot offset bugs, handling zero topOffset positioning, and clamping negative values in the weekly view.
Description check ✅ Passed The description is well-detailed and directly related to the changeset, explaining the three bugs fixed, including visual before/after screenshots and testing instructions.
Linked Issues check ✅ Passed The PR fully addresses the requirements from #14208: fixes marginTop misalignment, preserves absolute positioning for zero offsets, and prevents negative offset clipping.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the reported bugs: Empty.tsx and grid/index.tsx modifications fix slot positioning, and package.json update is a minimal dependency version bump likely required for bug fix compatibility.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ManthanNimodiya
Copy link
Copy Markdown
Author

@romitg2 please have a look when you get chance and let me know if any changes are required.
Also could you add the run-ci label so the CI checks runs

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 21, 2026

CLA assistant check
All committers have signed the CLA.

@github-actions
Copy link
Copy Markdown
Contributor

This PR has been marked as stale due to inactivity. If you're still working on it or need any help, please let us know or update the PR to keep it active.

@github-actions github-actions Bot added the Stale label May 29, 2026
@ManthanNimodiya
Copy link
Copy Markdown
Author

@romitg2, please have a look when you get chance also lmk for any changes

@github-actions github-actions Bot removed the Stale label Jun 2, 2026
@ManthanNimodiya ManthanNimodiya force-pushed the fix/weekly-view-slot-offset branch from b6cde9a to e1233d0 Compare June 7, 2026 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

booking-page area: booking page, public booking page, booker 🐛 bug Something isn't working 🙋🏻‍♂️help wanted Help from the community is appreciated Medium priority Created by Linear-GitHub Sync size/L ui area: UI, frontend, button, form, input

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Weekly view time slots offset and content overflow clipped

2 participants