From 2ee673a4e7ba7920cf4de5b8761f3ba36e1fc012 Mon Sep 17 00:00:00 2001 From: Mark Fayngersh Date: Tue, 16 Jul 2024 11:36:19 -0400 Subject: [PATCH] rows getter should react to `originalData` --- .changeset/sweet-books-obey.md | 5 +++++ src/lib/DataTable.svelte.ts | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 .changeset/sweet-books-obey.md 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;