Skip to content

Conversation

@ArgoZhang
Copy link
Member

@ArgoZhang ArgoZhang commented Nov 11, 2025

Link issues

fixes #7097

Summary By Copilot

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Update the date picker’s range styling by refactoring date classification logic and refining CSS rules to ensure start, end, and range styles are applied only to current month days

Bug Fixes:

  • Fix issue#7097 by updating start/end styling logic to correctly apply only to visible (current month) dates

Enhancements:

  • Introduce helper methods for classifying dates as previous, next, or current month, and for determining range membership
  • Restrict application of start, end, and range CSS classes to days in the current month
  • Simplify SCSS selectors for start and end states by removing explicit month qualifiers

Copilot AI review requested due to automatic review settings November 11, 2025 08:06
@bb-auto bb-auto bot added the enhancement New feature or request label Nov 11, 2025
@bb-auto bb-auto bot added this to the 10.0.0 milestone Nov 11, 2025
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Nov 11, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR refactors the DatePickerBody component by extracting month and range logic into dedicated helper methods, tightening the application of start/end/range CSS classes to current-month dates, and simplifying SCSS selectors for those states.

Class diagram for updated DatePickerBody logic

classDiagram
    class DatePickerBody {
        - DateTime CurrentDate
        - DateTime SelectValue
        - Ranger? Ranger
        + string? GetDayClass(DateTime day, bool overflow)
        + bool IsPrevMonth(DateTime day)
        + bool IsNextMonth(DateTime day)
        + bool IsCurrentMonth(DateTime day)
        + bool IsRange(DateTime day)
    }
Loading

Flow diagram for day class assignment logic

flowchart TD
    A["GetDayClass(day, overflow)"] --> B["IsPrevMonth(day)?"]
    B -- Yes --> C["Add 'prev-month' class"]
    B -- No --> D["IsNextMonth(day)?"]
    D -- Yes --> E["Add 'next-month' class"]
    D -- No --> F["IsCurrentMonth(day)?"]
    F -- Yes --> G["IsRange(day)?"]
    G -- Yes --> H["Add 'range' class"]
    G -- No --> I["Continue"]
    F -- No --> I
    A --> J["IsCurrentMonth(day) && day == Ranger.SelectedValue.Start.Date?"]
    J -- Yes --> K["Add 'start' class"]
    J -- No --> L["Continue"]
    A --> M["IsCurrentMonth(day) && day == Ranger.SelectedValue.End.Date?"]
    M -- Yes --> N["Add 'end' class"]
    M -- No --> O["Continue"]
    A --> P["IsDisabled(day) || overflow?"]
    P -- Yes --> Q["Add 'disabled' class"]
    P -- No --> R["Continue"]
Loading

File-Level Changes

Change Details Files
Extracted month and range evaluation into helper methods
  • Added IsPrevMonth, IsNextMonth, IsCurrentMonth, and IsRange helper methods
  • Replaced inline month and range checks in GetDayClass with these new methods
src/BootstrapBlazor/Components/DateTimePicker/DatePickerBody.razor.cs
Refined CSS class logic in GetDayClass to limit start/end/range to current month
  • Updated .AddClass("start") and .AddClass("end") calls to include current-month guard
  • Replaced range condition with IsRange combined with current-month check
src/BootstrapBlazor/Components/DateTimePicker/DatePickerBody.razor.cs
Simplified SCSS selectors for start and end states
  • Removed next-month and prev-month qualifiers from .start and .end selectors
  • Cleaned up SCSS import formatting
src/BootstrapBlazor/Components/DateTimePicker/DatePickerBody.razor.scss

Assessment against linked issues

Issue Objective Addressed Explanation
#7097 Update the visual style of the start and end dates in the DatetimeRange component.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-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.

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copilot finished reviewing on behalf of ArgoZhang November 11, 2025 08:07
@ArgoZhang ArgoZhang changed the title feat(DatetimeRange): update start/end style feat(DatetimeRange): simplify SCSS selectors for start and end Nov 11, 2025
@codecov
Copy link

codecov bot commented Nov 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (164a42e) to head (dfb049a).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #7098   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          745       745           
  Lines        32542     32548    +6     
  Branches      4509      4510    +1     
=========================================
+ Hits         32542     32548    +6     
Flag Coverage Δ
BB 100.00% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ArgoZhang ArgoZhang merged commit 5e93bb5 into main Nov 11, 2025
11 checks passed
@ArgoZhang ArgoZhang deleted the feat-range branch November 11, 2025 08:10
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 updates the styling logic for start/end dates in the DatetimeRange component to ensure these classes are only applied to dates within the current month being displayed.

Key Changes:

  • Simplified SCSS selectors by removing month-specific restrictions and moving logic to C#
  • Added IsCurrentMonth() condition to start/end/range CSS classes in the code
  • Extracted month comparison logic into reusable helper methods

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
DatePickerBody.razor.scss Simplified CSS selectors for .start and .end classes by removing :not(.next-month):not(.prev-month) conditions
DatePickerBody.razor.cs Added IsCurrentMonth() checks to start/end/range class logic and introduced helper methods for month comparisons

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +70 to +74
private bool IsPrevMonth(DateTime day) => day.Month < CurrentDate.Month;

private bool IsNextMonth(DateTime day) => day.Month > CurrentDate.Month;

private bool IsCurrentMonth(DateTime day) => day.Month == CurrentDate.Month;
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

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

The month comparison methods IsPrevMonth, IsNextMonth, and IsCurrentMonth only compare the month component without considering the year. This will cause incorrect behavior when the calendar displays dates that cross year boundaries.

For example:

  • When viewing January 2024, a date from December 2023 will incorrectly be classified as "next-month" (12 > 1) instead of "prev-month"
  • When viewing December 2024, a date from January 2025 will incorrectly be classified as "prev-month" (1 < 12) instead of "next-month"

Consider using a date comparison or year-aware logic:

private bool IsPrevMonth(DateTime day) => day.Year < CurrentDate.Year || (day.Year == CurrentDate.Year && day.Month < CurrentDate.Month);

private bool IsNextMonth(DateTime day) => day.Year > CurrentDate.Year || (day.Year == CurrentDate.Year && day.Month > CurrentDate.Month);

private bool IsCurrentMonth(DateTime day) => day.Year == CurrentDate.Year && day.Month == CurrentDate.Month;
Suggested change
private bool IsPrevMonth(DateTime day) => day.Month < CurrentDate.Month;
private bool IsNextMonth(DateTime day) => day.Month > CurrentDate.Month;
private bool IsCurrentMonth(DateTime day) => day.Month == CurrentDate.Month;
private bool IsPrevMonth(DateTime day) => day.Year < CurrentDate.Year || (day.Year == CurrentDate.Year && day.Month < CurrentDate.Month);
private bool IsNextMonth(DateTime day) => day.Year > CurrentDate.Year || (day.Year == CurrentDate.Year && day.Month > CurrentDate.Month);
private bool IsCurrentMonth(DateTime day) => day.Year == CurrentDate.Year && day.Month == CurrentDate.Month;

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(DatetimeRange): update start/end style

2 participants