From 8b076608f2756ae8079a04edd34981cd33698030 Mon Sep 17 00:00:00 2001 From: Emanuele Bardelli Date: Thu, 12 Dec 2024 07:45:42 -0800 Subject: [PATCH 1/9] Remove groupDataPopulated flag This flag doesn't get updated when the underlying data is changed. Removing it seems to fix tables not showing updated data on component changes. --- .../src/lib/unsorted/viz/table/_DataTable.svelte | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/ui/core-components/src/lib/unsorted/viz/table/_DataTable.svelte b/packages/ui/core-components/src/lib/unsorted/viz/table/_DataTable.svelte index 39aa6550ec..72f90f9ab3 100644 --- a/packages/ui/core-components/src/lib/unsorted/viz/table/_DataTable.svelte +++ b/packages/ui/core-components/src/lib/unsorted/viz/table/_DataTable.svelte @@ -130,13 +130,11 @@ $: showLinkCol = showLinkCol === 'true' || showLinkCol === true; let error = undefined; - let groupDataPopulated = false; // --------------------------------------------------------------------------------------- // Add props to store to let child components access them // --------------------------------------------------------------------------------------- props.update((d) => { - groupDataPopulated = false; return { ...d, data, columns: [] }; }); @@ -453,7 +451,7 @@ let groupRowData = []; $: if (!error) { - if (groupBy && !groupDataPopulated) { + if (groupBy) { groupedData = data.reduce((acc, row) => { const groupName = row[groupBy]; if (!acc[groupName]) { @@ -462,7 +460,6 @@ acc[groupName].push(row); return acc; }, {}); - groupDataPopulated = true; } // After groupedData is populated, calculate aggregations for groupRowData From eda30637aae098578502c8f54453ec2dfddf0d92 Mon Sep 17 00:00:00 2001 From: Emanuele Bardelli Date: Thu, 12 Dec 2024 09:18:02 -0800 Subject: [PATCH 2/9] Add changeset --- .changeset/twelve-toes-serve.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/twelve-toes-serve.md diff --git a/.changeset/twelve-toes-serve.md b/.changeset/twelve-toes-serve.md new file mode 100644 index 0000000000..42684b0b20 --- /dev/null +++ b/.changeset/twelve-toes-serve.md @@ -0,0 +1,5 @@ +--- +'@evidence-dev/core-components': patch +--- + +Remove groupDataPopulated flag From 91a6fcf0c942c3e7c2802a08709e4bfd3c2a5c9b Mon Sep 17 00:00:00 2001 From: kwongz Date: Fri, 20 Dec 2024 15:51:35 -0500 Subject: [PATCH 3/9] added filtered data groupby datatable story --- .../viz/table/DataTable.stories.svelte | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/packages/ui/core-components/src/lib/unsorted/viz/table/DataTable.stories.svelte b/packages/ui/core-components/src/lib/unsorted/viz/table/DataTable.stories.svelte index 78695f7e89..de225cf8ca 100644 --- a/packages/ui/core-components/src/lib/unsorted/viz/table/DataTable.stories.svelte +++ b/packages/ui/core-components/src/lib/unsorted/viz/table/DataTable.stories.svelte @@ -32,6 +32,15 @@ @@ -365,6 +374,26 @@

AreaMap Error

+ + {@const data = Query.create( + `SELECT * from flights where regulator in ('Afghanistan', 'Belgium', 'Canada', 'Denmark') limit 50`, + query + )} + {@const filteredData = Query.create( + `SELECT * from flights where regulator = '${$inputStore.regulator.value}' limit 10`, + query + )} + +

Normal Data

+ + + + + + +

Filtered Data

+ +
diff --git a/packages/ui/core-components/src/lib/unsorted/viz/table/_DataTable.svelte b/packages/ui/core-components/src/lib/unsorted/viz/table/_DataTable.svelte index 21228bcde2..264e4a17b4 100644 --- a/packages/ui/core-components/src/lib/unsorted/viz/table/_DataTable.svelte +++ b/packages/ui/core-components/src/lib/unsorted/viz/table/_DataTable.svelte @@ -31,8 +31,6 @@ import { browserDebounce } from '@evidence-dev/sdk/utils'; import { getThemeStores } from '../../../themes/themes.js'; - import { onMount } from 'svelte'; - const { resolveColor } = getThemeStores(); // Set up props store