malzariey/filament-daterangepicker-filter

Range Labels Not Respected for Default Start/End Date On Initial Load

Closed this issue · 1 comments

On initial load of the filter, the display label is the date range [06/16/2024 - 06/30/2024] instead of the range label "Last 14 days"

When using the filter Reset in filament, the correct label "Last 14 days" appears correctly.

Steps to reproduce:

  1. Set custom ranges
  2. Use Range Labels
  3. Set startDate and EndDate to match a range label

On initial load the range is displayed, on filter reset, the correct label is displayed

          DateRangeFilter::make('created_at')
                ->label('Date Range')
                ->disableClear()
                ->disableCustomRange()
                ->withIndicator()
                ->ranges([
                    'Today' => [now(), now()],
                    'Yesterday' => [now()->subDay(), now()->subDay()],
                    'Last 7 days' => [now()->subDays(7), now()],
                    'Last 14 days' => [now()->subDays(14), now()],
                    'Last 30 days' => [now()->subDays(30), now()],
                    'Last 60 days' => [now()->subDays(60), now()],
                    'Last 90 days' => [now()->subDays(90), now()],
                    'All Dates' => [now()->subYears(10), now()],
                ])
                ->useRangeLabels()
                ->startDate(now()->subDays(14))
                ->endDate(now())
                ->format('m/d/Y')
                ->displayFormat('MM/DD/YYYY')
                ->columnSpan(1)
                ->columns(1),

Fixed in v 2.8