From a32a49203dc786cdba4ee36b8aa4b5e6a9e4a0da Mon Sep 17 00:00:00 2001 From: Sean Oliver <882952+seanoliver@users.noreply.github.com> Date: Fri, 19 Sep 2025 11:16:04 -0700 Subject: [PATCH] fix: update template fields atomically to prevent state race conditions - Combine name, comment, and columns updates into single onUpdateField call - Fixes issue where fields weren't populating due to React closure stale state - Remove debug console.log statements --- .../SidePanelEditor/TableEditor/TableEditor.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx index b9af5aaaf6f..e6402151df7 100644 --- a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx +++ b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx @@ -286,9 +286,12 @@ export const TableEditor = ({ { - if (template.name) onUpdateField({ name: template.name }) - if (template.comment) onUpdateField({ comment: template.comment }) - if (template.columns) onUpdateField({ columns: template.columns }) + // Update all fields at once to avoid closure issues + const updates: Partial = {} + if (template.name) updates.name = template.name + if (template.comment) updates.comment = template.comment + if (template.columns) updates.columns = template.columns + onUpdateField(updates) }} disabled={false} />