malzariey / filament-daterangepicker-filter

MIT License
79 stars 39 forks source link

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

Closed ronfuller closed 3 weeks ago

ronfuller commented 3 weeks ago

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),
malzariey commented 3 weeks ago

Fixed in v 2.8