Skip to content

feat: improve DatePicker UX with smart month navigation #21930

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

Closed
wants to merge 5 commits into from

Conversation

Vansh5632
Copy link
Contributor

@Vansh5632 Vansh5632 commented Jun 19, 2025

Made changes in the datepicker element for handling the situation

-Fixes: #21831
-Fixes: CAL- 5928

video:

Screencast.from.2025-06-21.19-53-54.mp4

Summary by cubic

Improved the DatePicker so it now keeps the selected date visible even if it has no availability, and automatically moves to the next month when the current month has no available dates.

- Add automatic navigation to next month when current month has no availability
- Enhance includedDates logic to preserve selected date visibility
- Implement useMoveToNextMonthOnNoAvailability hook with loading state handling
- Only trigger auto-navigation for current month to avoid disrupting user intent
Copy link

vercel bot commented Jun 19, 2025

@Vansh5632 is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

@graphite-app graphite-app bot added the community Created by Linear-GitHub Sync label Jun 19, 2025
@graphite-app graphite-app bot requested a review from a team June 19, 2025 17:02
@CLAassistant
Copy link

CLAassistant commented Jun 19, 2025

CLA assistant check
All committers have signed the CLA.

@dosubot dosubot bot added bookings area: bookings, availability, timezones, double booking ✨ feature New feature or request labels Jun 19, 2025
Copy link

graphite-app bot commented Jun 19, 2025

Graphite Automations

"Add consumer team as reviewer" took an action on this PR • (06/19/25)

1 reviewer was added to this PR based on Keith Williams's automation.

"Add community label" took an action on this PR • (06/19/25)

1 label was added to this PR based on Keith Williams's automation.

"Add ready-for-e2e label" took an action on this PR • (06/23/25)

1 label was added to this PR based on Keith Williams's automation.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

cubic reviewed 1 file and found no issues. Review PR in cubic.dev.

React with 👍 or 👎 to teach cubic. Tag @cubic-dev-ai to give specific feedback.

@kart1ka
Copy link
Contributor

kart1ka commented Jun 21, 2025

Hey @Vansh5632. Thanks for the PR. Could you please add a loom video showing your fix?

@Vansh5632
Copy link
Contributor Author

added the video of showing the working of this

Copy link
Contributor

@Devanshusharma2005 Devanshusharma2005 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

github-actions bot commented Jun 23, 2025

E2E results are ready!

@Vansh5632
Copy link
Contributor Author

can anyone explain me the reason for the failing tests so i can fix that and make this PR ready for merging actually i am new to cal.com repo

@Devanshusharma2005
Copy link
Contributor

can anyone explain me the reason for the failing tests so i can fix that and make this PR ready for merging actually i am new to cal.com repo

you can check the reason of failing tests by clicking on the particular failing test.

@github-actions github-actions bot added the 🧹 Improvements Improvements to existing features. Mostly UX/UI label Jul 7, 2025
@anikdhabal
Copy link
Contributor

cc @SomayChauhan

@anikdhabal anikdhabal requested a review from SomayChauhan July 7, 2025 16:18
Copy link
Contributor

coderabbitai bot commented Jul 24, 2025

Walkthrough

The change modifies the logic in the DatePicker component to ensure that the currently selected date (selectedDate) is always included in the list of dates passed to the date picker UI, even if that date is not present in the available dates (nonEmptyScheduleDays). This is achieved by creating a new array, includedDatesWithSelected, which combines the original available dates with the selected date if it exists. The rest of the component's logic and its public interface remain unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/features/bookings/Booker/components/DatePicker.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-playwright".

(The package "eslint-plugin-playwright" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-playwright@latest --save-dev

The plugin "eslint-plugin-playwright" was referenced from the config file in ".eslintrc.js".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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: 0

🧹 Nitpick comments (1)
packages/features/bookings/Booker/components/DatePicker.tsx (1)

36-48: Consider Day.js performance impact in date filtering operations.

The code uses dayjs(date).isSame(browsingDate, "month") for filtering dates and browsingDate.add(1, "month") for navigation. According to coding guidelines, Day.js operations like .isSame() and .add() can be slow in performance-critical code, especially in timezone mode.

For better performance in this booking component, consider:

  • Using .utc() mode: dayjs(date).utc().isSame(browsingDate.utc(), "month")
  • Or using native Date operations for month comparisons
-  const nonEmptyScheduleDaysInBrowsingMonth = nonEmptyScheduleDays.filter((date) =>
-    dayjs(date).isSame(browsingDate, "month")
-  );
+  const nonEmptyScheduleDaysInBrowsingMonth = nonEmptyScheduleDays.filter((date) =>
+    dayjs(date).utc().isSame(browsingDate.utc(), "month")
+  );
-    onMonthChange(browsingDate.add(1, "month"));
+    onMonthChange(browsingDate.utc().add(1, "month"));
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3ab6767 and d91e4c1.

📒 Files selected for processing (1)
  • packages/features/bookings/Booker/components/DatePicker.tsx (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/review.mdc)

Flag excessive Day.js use in performance-critical code. Functions like .add, .diff, .isBefore, and .isAfter are slow, especially in timezone mode. Prefer .utc() for better performance. Where possible, replace with native Date and direct .valueOf() comparisons for faster execution. Recommend using native methods or Day.js .utc() consistently in hot paths like loops.

Files:

  • packages/features/bookings/Booker/components/DatePicker.tsx
🧠 Learnings (1)
packages/features/bookings/Booker/components/DatePicker.tsx (3)

Learnt from: CR
PR: calcom/cal.com#0
File: .cursor/rules/review.mdc:0-0
Timestamp: 2025-07-21T13:54:11.770Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Flag excessive Day.js use in performance-critical code. Functions like .add, .diff, .isBefore, and .isAfter are slow, especially in timezone mode. Prefer .utc() for better performance. Where possible, replace with native Date and direct .valueOf() comparisons for faster execution. Recommend using native methods or Day.js .utc() consistently in hot paths like loops.

Learnt from: Anshumancanrock
PR: #22570
File: apps/web/modules/signup-view.tsx:253-253
Timestamp: 2025-07-21T21:33:23.343Z
Learning: In signup-view.tsx, when checking if redirectUrl contains certain strings, using explicit && checks (redirectUrl && redirectUrl.includes()) is preferred over optional chaining (redirectUrl?.includes()) to ensure the result is always a boolean rather than potentially undefined. This approach provides cleaner boolean contracts for downstream conditional logic.

Learnt from: eunjae-lee
PR: #22106
File: packages/features/insights/components/FailedBookingsByField.tsx:65-71
Timestamp: 2025-07-15T12:59:34.389Z
Learning: In the FailedBookingsByField component (packages/features/insights/components/FailedBookingsByField.tsx), although routingFormId is typed as optional in useInsightsParameters, the system automatically enforces a routing form filter, so routingFormId is always present in practice. This means the data always contains only one entry, making the single-entry destructuring approach safe.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Install dependencies / Yarn install & cache
🔇 Additional comments (3)
packages/features/bookings/Booker/components/DatePicker.tsx (3)

102-109: LGTM! Clean implementation for including selected date.

The useMemo hook correctly ensures the selected date is always included in the date picker, even when it has no availability. The Set usage prevents duplicates and the dependencies are appropriate.


143-143: Prop includedDates correctly matches DatePickerComponent API

The DatePickerProps interface in packages/features/calendars/DatePicker.tsx defines:

export type DatePickerProps = {
  
  includedDates?: string[];
  
}

and the component uses props.includedDates internally. Passing includedDates={includedDatesWithSelected} aligns with this definition.


104-106: No format mismatch found—selectedDate and nonEmptyScheduleDays are both “YYYY-MM-DD” strings.

All calls to setSelectedDate use date.format("YYYY-MM-DD"), and useNonEmptyScheduleDays simply returns the object keys (typed as string[]) from slots, which are generated by the server in the same “YYYY-MM-DD” format. No further changes needed.

@SomayChauhan
Copy link
Member

closing as the pr doesn't solve the mentioned issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bookings area: bookings, availability, timezones, double booking community Created by Linear-GitHub Sync ✨ feature New feature or request 🧹 Improvements Improvements to existing features. Mostly UX/UI Low priority Created by Linear-GitHub Sync ready-for-e2e
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CAL-5927] [Atoms] - Allow selectedDate prop to select even if time-slot is unavailable
6 participants