Skip to content

Commit 94f0694

Browse files
committed
Ensure row access doesn't mutate state, see: sveltejs/svelte#12457
1 parent 6d1437c commit 94f0694

File tree

3 files changed

+28
-19
lines changed

3 files changed

+28
-19
lines changed

.changeset/friendly-squids-knock.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@careswitch/svelte-data-table': patch
3+
---
4+
5+
Ensure row access doesn't mutate state, see: https://github.com/sveltejs/svelte/issues/12457

package-lock.json

+16-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib/DataTable.svelte.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,8 @@ export class DataTable<T> {
4040
#globalFilter = $state<string>('');
4141
#globalFilterRegex = $state<RegExp | null>(null);
4242

43-
#isFilterDirty = $state(true);
44-
#isSortDirty = $state(true);
45-
43+
#isFilterDirty = true;
44+
#isSortDirty = true;
4645
#filteredData: T[] = [];
4746
#sortedData: T[] = [];
4847

@@ -165,6 +164,11 @@ export class DataTable<T> {
165164
* @returns {T[]} An array of rows for the current page.
166165
*/
167166
get rows() {
167+
// React to changes in filter state and sort state
168+
this.#filterState;
169+
this.#sortState;
170+
this.#globalFilterRegex;
171+
168172
this.#applyFilters();
169173
this.#applySort();
170174
const startIndex = (this.currentPage - 1) * this.#pageSize;

0 commit comments

Comments
 (0)