Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GridField Filter Tags Remove Button does not clear GridState GridFieldFilterHeader Column #9607

Open
scaventum opened this issue Jul 21, 2020 · 2 comments

Comments

@scaventum
Copy link

Affected Version

4.4.4

Description

I have a model admin which automatically implements GridField for displaying the list. What i noticed is when i apply filter on one or more fields, the GridField search box will then show filter tags which is very informative and also removable with [x] button next to it (so you can easily remove the filter).

The problem is when remove the filter tags by clicking the [x] button and checked the request by inspect element (network tab), the filter is still not cleared.

Steps to Reproduce

  1. Fresh install Silverstripe 4.4.4
  2. Create a simple DataObject
use SilverStripe\ORM\DataObject;

class Player extends DataObject 
{
    private static $db = [
        'PlayerNumber' => 'Int',
        'FirstName' => 'Varchar(255)',
        'LastName' => 'Text',
        'Birthday' => 'Date'
    ];

private static $summary_fields = [
        'PlayerNumber' => 'Player Number',
        'FirstName' => 'First Name',
        'LastName' => 'Last Name',
    ];
}
  1. Create simple ModelAdmin for that DataObject
use SilverStripe\Admin\ModelAdmin;

class MyAdmin extends ModelAdmin 
{

    private static $managed_models = [
        'Player'
    ];

    private static $url_segment = 'players';

    private static $menu_title = 'Player Admin';
}
  1. Open the ModelAdmin from CMS /admin/players, open inspect element (network tab)
  2. Filter the list by typing a keyword on FirstName field on top right, e.g. Bob
  3. The filter tag in search box should show ( x | First Name: Bob)
  4. Remove the filter tag by clicking (x)
  5. Look at the recently created request after clicking (x):
MyProject-DataObjects-Region[GridState]:
{
   "GridFieldSortableHeader":{
      "SortColumn":[

      ]
   },
   "GridFieldFilterHeader":{
      "Columns":{
         "FirstName":"Bob"
      }
   },
   "GridFieldPaginator":{
      "currentPage":1,
      "itemsPerPage":30
   },
   "Readonly":[

   ]
}

The question is why the GridFieldFilerHeader still has the filter Bob. I realize the grid shows the correct list of data. But i think this could be a bug if we have some tweaks on custom filters.

@Cheddam
Copy link
Member

Cheddam commented Jul 22, 2020

Thanks for the report, @scaventum!

@sminnee
Copy link
Member

sminnee commented Aug 18, 2020

FYI I've suggested building on #9190 to push grid field state into the URL via the history API, and have it be managed by GridField itself rather than selected components. This may assist with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants