Skip to content

Commit

Permalink
Fixes #8
Browse files Browse the repository at this point in the history
  • Loading branch information
afonic committed Jan 24, 2024
1 parent a94808a commit 21784af
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Http/Livewire/Traits/IsLivewireFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
9 changes: 9 additions & 0 deletions tests/Feature/LfCheckboxFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 21784af

Please sign in to comment.