Error when using localStorage with filter controls and cookies. #7261
Labels
Bug
Issues which are marked as Bug
cookie
Issues for the cookie extension.
filter-control
Issues for the filter-control extension.
Bootstraptable version(s) affected
1.22.4
Description
My table uses
data-filter-control="true"
anddata-show-search-clear-button="true"
. I also uselocalStorage
for saving my own cookies, nothing to do with bootstrap table. I have found that using the clear search button whilelocalStorage
contains cookies the following error is shown:As the error says, the problem is found in the following piece of code from Cookie extension:
because
t._storage
is undefined. Addingdata-cookie="true"
to the table makes the error go away becauset._storage
is not undefined, but this is not the point, since cookies should not be tried to be deleted if the table works without cookies.I made some debugging to know why cookies are being deleted if my table does not use cookies, and found out that
collectBootstrapTableFilterCookies
function, from Filter Control extension, is returning the cookies stored inlocalStorage
even when they have nothing to do with bootstrap table. Specifically the code that is causing so is:The problem is that any cookie's name stored in
localStorage
is returned by this method and afterwards those cookies will be deleted.Example(s)
I tried to reproduce it in the online editor but couldn't.
Possible Solutions
I think that changing the regular expression so it only matches with bootstrap-table cookies would solve the problem:
Additional Context
No response
The text was updated successfully, but these errors were encountered: