react-bootstrap-table/react-bootstrap-table2

Default Filter with Cookie extension Bug when clicking Clear button

mholtermann opened this issue · 0 comments

Describe the bug
Combining the Filter Control extension and cookie extension creates a bug when users click the clear button and have filter defaults set on the table.
Without the cookie plugin filter defaults clear correctly and display matching data on no filter.
With the cookie plugin the filter defaults clear and display data with no filters but the filter text or what is selected changes back to the default if the last filter you changed was not a filter with a default. If the last filter you changed was a filter with a default it appears to be cleared because your focus goes back to that field even though in the background the default is still saved, since if you press clear again the data will be restricted to the filter default even though the filter text or dropdown is empty because of your focus.

Basically I think after hitting clear the data should key off of the default filters, it only keys off of the default filters after pressing clear twice. Also when clicking clear all filters should be filled out with the default filter value even though you focus is given to the input or select element. After this fix probably a good idea would be to rename the button to "Reset" filters, and then create new functionality for a clear button to wipe out the default filters when hitting clear.

To Reproduce
Steps to reproduce the behavior:
Case 1

  1. Go to https://live.bootstrap-table.com/code/mholtermann/15120
  2. Change the last filter to $0
  3. Click clear, it looks ok but if you click clear again you will see that the filter is still holding the default even though the dropdown has blank selected.

Case 2

  1. Go to https://live.bootstrap-table.com/code/mholtermann/15120
  2. Change the last filter to $0
  3. Change the middle filter to Ite
  4. Click clear, the last dropdown says $0 is selected but the data does not match. If you click clear again the data will start to match the default filters again, the middle filter will still be blank even though the filter is passing the default in the backend.

First time posting an issue anywhere preview isn't working on gifs, links below in case they aren't working
https://s12.gifyu.com/images/2023-04-24-17-31-25.gif
https://s12.gifyu.com/images/2023-04-24-17-32-38.gif
https://s12.gifyu.com/images/2023-04-24-17-44-09.gif