diff --git a/src/Http/Livewire/Traits/IsLivewireFilter.php b/src/Http/Livewire/Traits/IsLivewireFilter.php index c28c92e..f4d54e7 100644 --- a/src/Http/Livewire/Traits/IsLivewireFilter.php +++ b/src/Http/Livewire/Traits/IsLivewireFilter.php @@ -74,6 +74,10 @@ protected function getParamKey() return 'taxonomy:'.$this->field.':'.$this->modifier; } + if ($this->condition === 'query_scope') { + return $this->modifier.':'.$this->field; + } + return $this->field.':'.$this->condition; } } diff --git a/tests/Feature/LfCheckboxFilterTest.php b/tests/Feature/LfCheckboxFilterTest.php index 7c5f717..3ac8eaa 100644 --- a/tests/Feature/LfCheckboxFilterTest.php +++ b/tests/Feature/LfCheckboxFilterTest.php @@ -191,6 +191,15 @@ public function it_loads_a_param_that_is_preset() ->assertSet('selected', ['option1']); } + /** @test */ + public function it_loads_a_param_that_is_preset_for_a_query_scope() + { + Livewire::test(LfCheckboxFilter::class, ['field' => 'item_options', 'collection' => 'pages', 'blueprint' => 'pages.pages', 'condition' => 'query_scope', 'modifier' => 'multiselect']) + ->assertSet('selected', []) + ->dispatch('preset-params', ['multiselect:item_options' => 'option1', 'query_scope' => 'multiselect']) + ->assertSet('selected', ['option1']); + } + protected function makeEntry($collection, $slug) { return EntryFactory::id($slug)->collection($collection)->slug($slug)->make();