From 2ae21fe123d7541641cb660078ef8b868fa1b6eb Mon Sep 17 00:00:00 2001 From: Camron Staley <55006027+CamronStaley@users.noreply.github.com> Date: Wed, 20 Nov 2024 10:34:32 -0600 Subject: [PATCH] fix panel rows not refreshing on action changes (#5164) --- .../plugins/SchemaIO/components/TableView.tsx | 49 +++++++++++-------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/app/packages/core/src/plugins/SchemaIO/components/TableView.tsx b/app/packages/core/src/plugins/SchemaIO/components/TableView.tsx index d31e9dbedd..9fbc83000e 100644 --- a/app/packages/core/src/plugins/SchemaIO/components/TableView.tsx +++ b/app/packages/core/src/plugins/SchemaIO/components/TableView.tsx @@ -35,7 +35,7 @@ export default function TableView(props: ViewPropsType) { size = "small", variant = "filled", max_inline_actions = 1, - tooltips = [] + tooltips = [], } = view; const { rows, selectedCells, selectedRows, selectedColumns } = getTableData(props); @@ -47,23 +47,26 @@ export default function TableView(props: ViewPropsType) { const selectedCellColor = selected_color || theme.palette.background.activeCell; - const getRowActions = useCallback((row) => { - const computedRowActions = [] as any; - for (const action of row_actions) { - if (action.rows?.[row] !== false) { - computedRowActions.push({ - ...action, - onClick: (action, e) => { - handleClick(panelId, { - operator: action.on_click, - params: { path, event: action.name, row }, - }); - }, - }); + const getRowActions = useCallback( + (row) => { + const computedRowActions = [] as any; + for (const action of row_actions) { + if (action.rows?.[row] !== false) { + computedRowActions.push({ + ...action, + onClick: (action, e) => { + handleClick(panelId, { + operator: action.on_click, + params: { path, event: action.name, row }, + }); + }, + }); + } } - } - return computedRowActions; - }, []); + return computedRowActions; + }, + [row_actions, handleClick, panelId, path] + ); const getTooltips = useCallback((tooltipList) => { const tooltipDict = {}; @@ -181,14 +184,16 @@ export default function TableView(props: ViewPropsType) { selectedCells.has(coordinate) || isRowSelected || selectedColumns.has(columnIndex); - + const tooltip = tooltipMap[coordinate]; // Check if there's a tooltip for the cell const content = formatCellValue(item[key], props); const cell = ( { handleCellClick(rowIndex, columnIndex); @@ -199,10 +204,12 @@ export default function TableView(props: ViewPropsType) { {content} - ) : (content)} + ) : ( + content + )} ); - + return cell; })}