Skip to content

Fix calendar auto-jump to next month when no slots are available#28887

Open
rakshityadav1868 wants to merge 5 commits intocalcom:mainfrom
rakshityadav1868:fixing-month-jump
Open

Fix calendar auto-jump to next month when no slots are available#28887
rakshityadav1868 wants to merge 5 commits intocalcom:mainfrom
rakshityadav1868:fixing-month-jump

Conversation

@rakshityadav1868
Copy link
Copy Markdown
Contributor

What does this PR do?

This PR fixes an issue where the calendar automatically jumps to the next month when there are no available slots in the current month, preventing users from navigating back.

Previously, if a month (e.g., April) had no availability, the calendar would auto-switch to the next available month (e.g., May). However, users were unable to return to the original month, leading to a confusing and restrictive experience.

BEFORE:

Screen.Recording.2026-04-14.at.7.15.55.PM.mp4

AFTER:

Screen.Recording.2026-04-14.at.7.17.27.PM.mp4

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 in /docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

…urrent month

Signed-off-by: Rakshit Yadav <yadavrakshit60@gmail.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 14, 2026

Hey there and thank you for opening this pull request! 👋🏼

We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted.

Details:

No release type found in pull request title "Fix calendar auto-jump to next month when no slots are available". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/

Available types:
 - feat: A new feature
 - fix: A bug fix
 - docs: Documentation only changes
 - style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
 - refactor: A code change that neither fixes a bug nor adds a feature
 - perf: A code change that improves performance
 - test: Adding missing tests or correcting existing tests
 - build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
 - ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
 - chore: Other changes that don't modify src or test files
 - revert: Reverts a previous commit

@github-actions github-actions bot added the 🐛 bug Something isn't working label Apr 14, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 14, 2026

📝 Walkthrough

Walkthrough

The DatePicker component no longer calls moveToNextMonthOnNoAvailability() during render. The auto-advance is now performed inside a useEffect that runs after isLoading becomes false and is guarded by a useRef so it executes only once per component lifecycle. This prevents the month-advance from running during initial render or while loading and stops repeated jumps on subsequent isLoading updates. No exported or public signatures were changed.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: fixing the calendar auto-jump behavior when no slots are available.
Description check ✅ Passed The description provides relevant context about the bug being fixed, links to the issue, includes before/after visuals, and confirms mandatory tasks completion.
Linked Issues check ✅ Passed The PR changes directly address issue #28885 by deferring the auto-jump logic to useEffect, preventing the unintended month-forward behavior described in the linked issue.
Out of Scope Changes check ✅ Passed All changes in DatePicker.tsx are focused on fixing the auto-jump behavior; no unrelated modifications are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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.

Copy link
Copy Markdown
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.

🧹 Nitpick comments (1)
apps/web/modules/bookings/components/DatePicker.tsx (1)

105-113: Remove the now-dead auto-jump binding to avoid maintenance drift.

The behavior fix is correct—the callback invocation is intentionally commented out. However, moveToNextMonthOnNoAvailability remains destructured but unused, and the useMoveToNextMonthOnNoAvailability hook is called only to supply this unused binding. Removing the hook call and binding simplifies the code and eliminates dead code.

♻️ Suggested cleanup
-  const { moveToNextMonthOnNoAvailability } = useMoveToNextMonthOnNoAvailability({
-    browsingDate,
-    nonEmptyScheduleDays,
-    onMonthChange,
-    isLoading: isLoading ?? true,
-  });
   // Disabled auto-jump to allow users to stay in current month
-  // moveToNextMonthOnNoAvailability();
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/web/modules/bookings/components/DatePicker.tsx` around lines 105 - 113,
Remove the now-unused auto-jump binding by deleting the call to
useMoveToNextMonthOnNoAvailability and the destructured
moveToNextMonthOnNoAvailability variable; update the surrounding code to pass
existing props (browsingDate, nonEmptyScheduleDays, onMonthChange, isLoading)
directly where needed without invoking the hook, and also remove any import of
useMoveToNextMonthOnNoAvailability if it becomes unused; ensure no other
references to moveToNextMonthOnNoAvailability remain.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@apps/web/modules/bookings/components/DatePicker.tsx`:
- Around line 105-113: Remove the now-unused auto-jump binding by deleting the
call to useMoveToNextMonthOnNoAvailability and the destructured
moveToNextMonthOnNoAvailability variable; update the surrounding code to pass
existing props (browsingDate, nonEmptyScheduleDays, onMonthChange, isLoading)
directly where needed without invoking the hook, and also remove any import of
useMoveToNextMonthOnNoAvailability if it becomes unused; ensure no other
references to moveToNextMonthOnNoAvailability remain.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1c1886fa-e446-4334-aca6-9ac6678068a7

📥 Commits

Reviewing files that changed from the base of the PR and between c0d105e and 5b32b61.

📒 Files selected for processing (1)
  • apps/web/modules/bookings/components/DatePicker.tsx

Copy link
Copy Markdown
Member

@romitg2 romitg2 left a comment

Choose a reason for hiding this comment

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

can we make autojumptonextmonth on initial load, but allow to go to previous month thereafter.

Signed-off-by: Rakshit Yadav <yadavrakshit60@gmail.com>
@rakshityadav1868
Copy link
Copy Markdown
Contributor Author

Screen.Recording.2026-04-14.at.8.13.25.PM.mp4

Applied the changes @romitg2, now moveToNextMonthOnNoAvailability will only be rendered on initial load using UseEffect, UseRef hooks.

Copy link
Copy Markdown
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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/web/modules/bookings/components/DatePicker.tsx (1)

106-120: ⚠️ Potential issue | 🟡 Minor

Normalize loading state before one-time jump gating.

Line 110 treats undefined as loading (isLoading ?? true), but Line 116 treats undefined as loaded (!isLoading). That mismatch can flip hasInitialJumpOccurred too early and prevent the intended first jump once loading actually completes.

🔧 Suggested fix
+  const resolvedIsLoading = isLoading ?? true;
   const { moveToNextMonthOnNoAvailability } = useMoveToNextMonthOnNoAvailability({
     browsingDate,
     nonEmptyScheduleDays,
     onMonthChange,
-    isLoading: isLoading ?? true,
+    isLoading: resolvedIsLoading,
   });
   const hasInitialJumpOccurred = useRef(false);

   useEffect(() => {
-    // Only auto-jump on initial load when data is loaded
-    if (!isLoading && !hasInitialJumpOccurred.current) {
-      moveToNextMonthOnNoAvailability();
-      hasInitialJumpOccurred.current = true;
-    }
-  }, [isLoading]);
+    if (resolvedIsLoading || hasInitialJumpOccurred.current) return;
+    moveToNextMonthOnNoAvailability();
+    hasInitialJumpOccurred.current = true;
+  }, [resolvedIsLoading, moveToNextMonthOnNoAvailability]);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/web/modules/bookings/components/DatePicker.tsx` around lines 106 - 120,
The component mixes raw isLoading and a different defaulted value (isLoading ??
true) which causes the initial-jump gating to misfire; normalize the loading
state once (e.g., const normalizedIsLoading = isLoading ?? true) and use that
same normalized variable both when calling useMoveToNextMonthOnNoAvailability
and inside the useEffect that checks hasInitialJumpOccurred, so
moveToNextMonthOnNoAvailability only runs after the consistent “loaded” state is
observed; refer to useMoveToNextMonthOnNoAvailability,
moveToNextMonthOnNoAvailability, hasInitialJumpOccurred, isLoading, and the
useEffect for where to apply the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@apps/web/modules/bookings/components/DatePicker.tsx`:
- Around line 106-120: The component mixes raw isLoading and a different
defaulted value (isLoading ?? true) which causes the initial-jump gating to
misfire; normalize the loading state once (e.g., const normalizedIsLoading =
isLoading ?? true) and use that same normalized variable both when calling
useMoveToNextMonthOnNoAvailability and inside the useEffect that checks
hasInitialJumpOccurred, so moveToNextMonthOnNoAvailability only runs after the
consistent “loaded” state is observed; refer to
useMoveToNextMonthOnNoAvailability, moveToNextMonthOnNoAvailability,
hasInitialJumpOccurred, isLoading, and the useEffect for where to apply the
change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1057661c-ccd0-41d7-89ba-c5708461195d

📥 Commits

Reviewing files that changed from the base of the PR and between 5b32b61 and 2bd920f.

📒 Files selected for processing (1)
  • apps/web/modules/bookings/components/DatePicker.tsx

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

Labels

🐛 bug Something isn't working ready-for-e2e size/S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Month jumps ahead, cannot be changed back to current month

3 participants