Skip to content

Commit 41da712

Browse files
committed
Datatables Persistent URL Tracking Fix
Under certain circumstances we want to render a table but not remember filtering. The flag for disabling table persistence is correct in that it doesn't trigger the redirect, however any changes made while that page is loaded still updates the localStorage value tracking filters so when a user returns to the regular persistence-enabled table it recreates the non-persistent state. Update assures the the localStorage value code only runs when table persistence is enabled.
1 parent ec3d9de commit 41da712

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/resources/views/crud/inc/datatables_logic.blade.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ functionsToRunOnDataTablesDrawEvent: [],
138138
newUrl = params_arr.length ? tmpUrl + "?" + params_arr.join("&") : tmpUrl;
139139
}
140140
window.history.pushState({}, '', newUrl);
141-
localStorage.setItem('{{ Str::slug($crud->getRoute()) }}_list_url', newUrl);
141+
@if ($crud->getPersistentTable())
142+
localStorage.setItem('{{ Str::slug($crud->getRoute()) }}_list_url', newUrl);
143+
@endif
142144
},
143145
dataTableConfiguration: {
144146
bInfo: {{ var_export($crud->getOperationSetting('showEntryCount') ?? true) }},

0 commit comments

Comments
 (0)