Skip to content

Commit

Permalink
fix panel rows not refreshing on action changes (#5164)
Browse files Browse the repository at this point in the history
  • Loading branch information
CamronStaley authored Nov 20, 2024
1 parent ebf6b56 commit 2ae21fe
Showing 1 changed file with 28 additions and 21 deletions.
49 changes: 28 additions & 21 deletions app/packages/core/src/plugins/SchemaIO/components/TableView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 = {};
Expand Down Expand Up @@ -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 = (
<TableCell
key={key}
sx={{
background: isSelected ? selectedCellColor : "unset",
background: isSelected
? selectedCellColor
: "unset",
}}
onClick={() => {
handleCellClick(rowIndex, columnIndex);
Expand All @@ -199,10 +204,12 @@ export default function TableView(props: ViewPropsType) {
<Tooltip title={tooltip} arrow>
<span> {content} </span>
</Tooltip>
) : (content)}
) : (
content
)}
</TableCell>
);

return cell;
})}

Expand Down

0 comments on commit 2ae21fe

Please sign in to comment.