Skip to content

Date range calendar filter starts on Tuesday when configureMondayFirst(true) is set #637

@romainalcon

Description

@romainalcon

Summary

When using DateRangeRequiredFilter or DateRangeFilter with configureMondayFirst(true), the date range picker displays Tuesday as the first column in the week grid. If I set configureMondayFirst(false), the first column is Monday as expected.
This suggests an inversion or off-by-one issue in the front-end calendar week-start logic when Monday-first is enabled.

Environment

  • Sharp: v9.10.1
  • Laravel: v12.32.5
  • PHP: constrained by Sharp to 8.3.|8.4. (project runs on PHP 8.4 in our environment)
  • Timezone: Europe/Paris (from config/app.php)
  • Laravel locale: fr (from config/app.php)
  • Carbon: bundled via Laravel ^3.8.4

Note: The behavior was reproduced in multiple browsers; it does not seem browser-specific.

Affected components

  • Filters: Code16\Sharp\Filters\DateRangeRequiredFilter, Code16\Sharp\Filters\DateRangeFilter

Minimal configuration that triggers the bug

use Carbon\Carbon;
use Code16\Sharp\Filters\DateRangeRequiredFilter;
use Code16\Sharp\Filters\DateRange\DateRangePreset;

class ExpenseDateFilter extends DateRangeRequiredFilter
{
    public function buildFilterConfig(): void
    {
        $this
            ->configureLabel('Date')
            ->configureKey('expense_date')
            ->configureMondayFirst(true) // problem manifests here
            ->configureShowPresets(true, [
                DateRangePreset::make(Carbon::now()->startOfWeek(), Carbon::now()->endOfWeek(), 'This week'),
                DateRangePreset::make(Carbon::now()->subWeek()->startOfWeek(), Carbon::now()->subWeek()->endOfWeek(), 'Last week'),
                DateRangePreset::make(Carbon::now()->startOfMonth(), Carbon::now()->endOfMonth(), 'This month'),
            ]);
    }

    public function defaultValue(): array
    {
        return [
            'start' => Carbon::now()->startOfWeek(),
            'end' => Carbon::now()->endOfWeek(),
        ];
    }
}

Note: In our project we also tested with configureMondayFirst(false); with false, the grid starts on Monday (which is counterintuitive), and with true it starts on Tuesday.

Steps to reproduce

  1. Create a DateRangeRequiredFilter (or DateRangeFilter) and call configureMondayFirst(true).
  2. Set any default or preset range (e.g., current week using Carbon::now()->startOfWeek()/endOfWeek()).
  3. Load the list view with the filter.
  4. Observe the date range picker grid: the first column is Tuesday, not Monday.

Observed behavior

  • With configureMondayFirst(true) on filters, the calendar grid starts on Tuesday.
  • With configureMondayFirst(false), the grid starts on Monday.

This looks like an inversion/misalignment in the Monday-first handling on the front-end.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions