diff --git a/.changeset/sweet-books-obey.md b/.changeset/sweet-books-obey.md new file mode 100644 index 0000000..f5e2dbf --- /dev/null +++ b/.changeset/sweet-books-obey.md @@ -0,0 +1,5 @@ +--- +'@careswitch/svelte-data-table': patch +--- + +rows getter should react to `originalData` diff --git a/src/lib/DataTable.svelte.ts b/src/lib/DataTable.svelte.ts index f2ca7ce..50bf04c 100644 --- a/src/lib/DataTable.svelte.ts +++ b/src/lib/DataTable.svelte.ts @@ -154,10 +154,9 @@ export class DataTable { * @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]; } /** @@ -165,7 +164,8 @@ export class DataTable { * @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;