Skip to content

Table summary row + Inline add new row #1114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Aug 27, 2024
Prev Previous commit
Next Next commit
fix status column edited value doesn't persist
  • Loading branch information
raheeliftikhar5 committed Aug 27, 2024
commit b31cae170230b0a328b6e84aef221bc683bd4ab6
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export function EditableCell<T extends JSONValue>(props: EditableCellProps<T>) {

useEffect(() => {
setTmpValue(value);
}, [value]);
}, [JSON.stringify(value)]);

const onChange = useCallback(
(value: T) => {
Expand All @@ -125,11 +125,11 @@ export function EditableCell<T extends JSONValue>(props: EditableCellProps<T>) {
if(!_.isEqual(tmpValue, value)) {
onTableEvent?.('columnEdited');
}
}, [dispatch, baseValue, tmpValue]);
}, [dispatch, JSON.stringify(baseValue), JSON.stringify(tmpValue)]);

const editView = useMemo(
() => editViewFn?.({ value, onChange, onChangeEnd }) ?? <></>,
[editViewFn, value, onChange, onChangeEnd]
[editViewFn, JSON.stringify(value), onChange, onChangeEnd]
);

const enterEditFn = useCallback(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,15 +325,6 @@ const TableWrapper = styled.div<{
border-top-right-radius: 0px;
}
}

// hide the bottom border of the last row
${(props) =>
props.$toolbarPosition !== "below" &&
`
tbody > tr:last-child > td {
border-bottom: unset;
}
`}
}

.ant-table-expanded-row-fixed:after {
Expand Down Expand Up @@ -948,6 +939,7 @@ export function TableCompView(props: {
return (
<TableSummary
tableSize={size}
istoolbarPositionBelow={toolbar.position === "below"}
expandableRows={Boolean(expansion.expandModalView)}
summaryRows={parseInt(summaryRows)}
columns={columns}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,19 @@ import Table from "antd/es/table";
import { ReactNode } from "react";
import Tooltip from "antd/es/tooltip";

const TableSummaryRow = styled(Table.Summary.Row)`
const TableSummaryRow = styled(Table.Summary.Row)<{
$istoolbarPositionBelow: boolean;
}>`
td:last-child {
border-right: unset !important;
}

${props => !props.$istoolbarPositionBelow && `
&:last-child td {
border-bottom: none !important;
}
`}

`;

const TableSummarCell = styled(Table.Summary.Cell)<{
Expand Down Expand Up @@ -168,13 +177,15 @@ export function TableSummary(props: {
summaryRows: number;
columns: ColumnComp[];
summaryRowStyle: TableSummaryRowStyleType;
istoolbarPositionBelow: boolean;
}) {
const {
columns,
summaryRows,
summaryRowStyle,
tableSize,
expandableRows,
istoolbarPositionBelow,
} = props;
let visibleColumns = columns.filter(col => !col.getView().hide);
if (expandableRows) {
Expand All @@ -186,7 +197,7 @@ export function TableSummary(props: {
return (
<Table.Summary>
{Array.from(Array(summaryRows)).map((_, rowIndex) => (
<TableSummaryRow key={rowIndex}>
<TableSummaryRow key={rowIndex} $istoolbarPositionBelow={istoolbarPositionBelow}>
{visibleColumns.map((column, index) => {
const summaryColumn = column.children.summaryColumns.getView()[rowIndex].getView();
return (
Expand Down