Skip to content

[WEB-4834] fix: range date picker weekStartsOn#7699

Merged
pushya22 merged 2 commits intopreviewfrom
fix-range-date-picker-start-of-the-week
Sep 2, 2025
Merged

[WEB-4834] fix: range date picker weekStartsOn#7699
pushya22 merged 2 commits intopreviewfrom
fix-range-date-picker-start-of-the-week

Conversation

@anmolsinghbhatia
Copy link
Collaborator

@anmolsinghbhatia anmolsinghbhatia commented Sep 2, 2025

Description

This PR updates the range date picker to respect the user’s weekStartsOn preference, ensuring the week now begins according to the user’s chosen setting.

Type of Change

  • Bug fix

Summary by CodeRabbit

  • New Features
    • Date Range dropdown calendar now respects your profile’s start-of-week preference (e.g., Monday or Sunday) for a more personalized experience.
    • Changes to your start-of-week preference are reflected immediately in the calendar.
    • Improves consistency with regional norms when viewing and selecting date ranges, reducing confusion and making range selection more intuitive.

@anmolsinghbhatia anmolsinghbhatia self-assigned this Sep 2, 2025
Copilot AI review requested due to automatic review settings September 2, 2025 08:53
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 2, 2025

Walkthrough

The DateRangeDropdown component is wrapped with MobX observer, now reads the user profile’s start_of_the_week via useUserProfile, computes startOfWeek, and passes weekStartsOn to the Calendar picker. No other structural changes beyond adjusting the export to observer(...) are included.

Changes

Cohort / File(s) Summary
DateRangeDropdown component
apps/web/core/components/dropdowns/date-range.tsx
Wrap component with observer(...); import and use useUserProfile to read data.start_of_the_week; derive startOfWeek; pass weekStartsOn={startOfWeek} to Calendar; update export signature accordingly.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant DateRangeDropdown as DateRangeDropdown (observer)
  participant UserProfile as User Profile Store
  participant Calendar as Calendar UI

  User->>DateRangeDropdown: Open dropdown / render
  DateRangeDropdown->>UserProfile: Read data.start_of_the_week
  UserProfile-->>DateRangeDropdown: startOfWeek
  DateRangeDropdown->>Calendar: Render with weekStartsOn = startOfWeek

  note over DateRangeDropdown,Calendar: With MobX observer, changes to user profile re-render Calendar with updated week start.
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

🐛bug

Suggested reviewers

  • prateekshourya29
  • vamsikrishnamathala
  • sriramveeraghanta

Poem

A hop, a skip, a weekday tweak—
My calendar now starts unique!
MobX ears perk, reacting quick,
Week’s first dawn I deftly pick.
Thump-thump feet set pace to seek—
Dates align, sleek-quick-chic. 🐇📅

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-range-date-picker-start-of-the-week

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
🪧 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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit 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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@anmolsinghbhatia anmolsinghbhatia linked an issue Sep 2, 2025 that may be closed by this pull request
1 task
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug in the range date picker component to respect the user's weekStartsOn preference. The component now retrieves the user's week start preference from their profile and applies it to the calendar component.

  • Converts the DateRangeDropdown component to use MobX observer pattern for reactive state management
  • Integrates user profile data to retrieve the week start preference
  • Passes the weekStartsOn prop to the Calendar component

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@makeplane
Copy link

makeplane bot commented Sep 2, 2025

Pull Request Linked with Plane Work Items

Comment Automatically Generated by Plane

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 (2)
apps/web/core/components/dropdowns/date-range.tsx (2)

5-5: Prefer mobx-react-lite for function components

Use mobx-react-lite to avoid pulling legacy class-based bits and keep bundle lean.

-import { observer } from "mobx-react";
+import { observer } from "mobx-react-lite";

64-64: Type the observer wrapper idiomatically to retain displayName and precise props typing

Small style/tstype improvement.

-export const DateRangeDropdown: React.FC<Props> = observer((props) => {
+export const DateRangeDropdown = observer(function DateRangeDropdown(props: Props) {
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 2d31b56 and cd63cca.

📒 Files selected for processing (1)
  • apps/web/core/components/dropdowns/date-range.tsx (5 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
apps/web/core/components/dropdowns/date-range.tsx (1)
apps/space/core/hooks/store/use-user-profile.ts (1)
  • useUserProfile (7-11)
⏰ 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). (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Build and lint web apps
🔇 Additional comments (2)
apps/web/core/components/dropdowns/date-range.tsx (2)

282-282: LGTM: Calendar now honors the user’s week start

Passing weekStartsOn addresses the reported bug.


100-103: Clamp/map start_of_the_week to 0–6 and support string weekdays
Clamp numeric values to [0,6] and map string names (“sunday”→0, “monday”→1, …) to avoid misconfiguring DayPicker if upstream changes. Confirm whether the store already guarantees a 0–6 integer; if so, you can drop the string branch.

@pushya22 pushya22 merged commit 779a96a into preview Sep 2, 2025
7 of 8 checks passed
@pushya22 pushya22 deleted the fix-range-date-picker-start-of-the-week branch September 2, 2025 12:32
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.

[bug]: Start of the week setting isn't respected

4 participants