rappasoft / laravel-livewire-tables

A dynamic table component for Laravel Livewire
https://rappasoft.com/docs/laravel-livewire-tables/v2/introduction
MIT License
1.75k stars 328 forks source link

[Bug]: Date filters not correct after reload #1954

Open edwinvdpol opened 4 days ago

edwinvdpol commented 4 days ago

What happened?

Date filters are changed on page reload.

How to reproduce the bug

When you set a date filter, and you refresh the page, the date filter changes to the default value instead the one from the URL.

This is how I set the filter:

DateFilter::make('Start Date')
    ->config(['max' => '2024-09-18'])
    ->setFilterDefaultValue(Date::today()->subDays(90)->toDateString()),

When the filter is set to for example: 2024-01-01 (visible in the URL), it shouldn't apply the default value.

Package Version

3.4.20

PHP Version

8.2.x

Laravel Version

11.22.0

Alpine Version

3.13.10

Theme

Bootstrap 4.x

Notes

No response

Error Message

No response

lrljoe commented 3 days ago

Is this just applying to the date filter?

lrljoe commented 2 days ago

@edwinvdpol Does this respect the session value if stored?

i.e. add

        $this->storeFiltersInSessionEnabled();

to your configure method:

public function configure(): void
{
}

I'll definitely look at it, as it should 100% respect what's set in the queryString, can you share the content of your configure() method (including any traits that use configuring/configured hooks) to help me replicate the issue please!

lrljoe commented 2 days ago

Looks like the mix of the two server-side arrays has caused this. It's high up on the to-do list to merge them properly (it was a hangover from the initial Livewire v3 migration)

However, the PR I've referenced should remediate it, expect this to be merged in this weekend.