Skip to content

Commit 8b497f6

Browse files
authored
Fix Reset button localStorage key mismatch (#5904) (#5905)
1 parent a73d122 commit 8b497f6

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/resources/views/crud/components/datatable/datatable_logic.blade.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -634,10 +634,11 @@ function setupTableUI(tableId, config) {
634634
localStorage.removeItem(`${config.persistentTableSlug}_list_url_time`);
635635
}
636636
637-
// Clear the table sorting/ordering/visibility
638-
if(localStorage.getItem(`DataTables_${tableId}_/${config.urlStart}`)) {
639-
localStorage.removeItem(`DataTables_${tableId}_/${config.urlStart}`);
640-
}
637+
// Clear ALL DataTables localStorage keys for this table
638+
// Fixes key mismatch where DataTables 2.x uses pathname-based keys
639+
Object.keys(localStorage)
640+
.filter(key => key.startsWith(`DataTables_${tableId}`))
641+
.forEach(key => localStorage.removeItem(key));
641642
});
642643
}
643644

0 commit comments

Comments
 (0)