Skip to content

Commit

Permalink
rows getter should react to originalData
Browse files Browse the repository at this point in the history
  • Loading branch information
pheuter committed Jul 16, 2024
1 parent 167367d commit 2ee673a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/sweet-books-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@careswitch/svelte-data-table': patch
---

rows getter should react to `originalData`
6 changes: 3 additions & 3 deletions src/lib/DataTable.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,18 @@ export class DataTable<T> {
* @param {T[]} rows - The array of rows to reset the base data to.
*/
set baseRows(rows: T[]) {
this.#originalData = [...rows];
this.#currentPage = 1;
this.#isFilterDirty = true;
this.#filterState = this.#filterState;
this.#originalData = [...rows];
}

/**
* The current page of rows based on applied filters and sorting.
* @returns {T[]} An array of rows for the current page.
*/
get rows() {
// React to changes in filter state and sort state
// React to changes in original data, filter state, and sort state
this.#originalData;
this.#filterState;
this.#sortState;
this.#globalFilterRegex;
Expand Down

0 comments on commit 2ee673a

Please sign in to comment.