From d88db0db5ae87ed048d1598612c6668ea215ea60 Mon Sep 17 00:00:00 2001 From: Sebastian Jeltsch Date: Fri, 18 Jul 2025 21:46:37 +0200 Subject: [PATCH] Refetch table data to re-render table after re-fetching the table schema. --- .../js/admin/src/components/tables/TablePane.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/trailbase-assets/js/admin/src/components/tables/TablePane.tsx b/trailbase-assets/js/admin/src/components/tables/TablePane.tsx index 971995fe..221ce3f6 100644 --- a/trailbase-assets/js/admin/src/components/tables/TablePane.tsx +++ b/trailbase-assets/js/admin/src/components/tables/TablePane.tsx @@ -775,10 +775,17 @@ export function TablePane(props: { })); const client = useQueryClient(); - const rowsRefetch = () => + const rowsRefetch = () => { + // Refetches the actual table contents above. client.invalidateQueries({ queryKey: ["tableData"], }); + }; + const schemaRefetch = async () => { + // First re-fetch the schema then the data rows to trigger a re-render. + await props.schemaRefetch(); + rowsRefetch(); + }; const setPagination = (s: PaginationState) => { const current = pagination(); @@ -807,7 +814,7 @@ export function TablePane(props: { indexes={indexes()} triggers={triggers()} allTables={props.schemas.tables} - schemaRefetch={props.schemaRefetch} + schemaRefetch={schemaRefetch} rowsRefetch={rowsRefetch} />