orchidsoftware / platform

Orchid is a @laravel package that allows for rapid application development of back-office applications, admin/user panels, and dashboards.
https://orchid.software
MIT License
4.26k stars 631 forks source link

Select filter resets after apply others #2822

Closed ShamazinGG closed 2 months ago

ShamazinGG commented 2 months ago

Describe the bug Select filter resets after apply others, when a list is passed to the options method of a Select class. It happens coz in src/Screen/Fields/Select.php 74 $isOptionList is true. Why do we need this check? To Reproduce Steps to reproduce the behavior:

  1. Create Filter Like this:
    class CoolFilter extends Filter
    {
    public function display(): array
    {
        return [
            Select::make('foo')
                ->empty()
                ->value($this->request->get('foo'))
                ->options([
                         0 => 'value0',
                         1 => 'value1',
                         2 => 'value2'
                ])
                ->title('bar')
        ];
     }
     //other default filter code
    }
  2. Add it to your FiltersLayout
  3. Create any other filter and add it to same FiltersLayout
  4. Apply Filter from s.1(CoolFilter) and then apply any other

Facted behavior Select filter resets, applied only last filter

Expected behavior Both filters applied

Server (please complete the following information):

Additional context In my project i customized select.blade.php and it works for me, but i`m not sure is a good solution, coz $isOptionList variable is not using in select.blade.php

Possible PR: https://github.com/orchidsoftware/platform/pull/2821

ShamazinGG commented 2 months ago

found the solution in https://github.com/orchidsoftware/platform/issues/2782