Skip to content

Commit 3abeeb4

Browse files
committed
fixes #548 better
1 parent 338f1e3 commit 3abeeb4

File tree

4 files changed

+9
-12
lines changed

4 files changed

+9
-12
lines changed

packages/material-react-table/src/components/body/MRT_TableBodyCell.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,7 @@ export const MRT_TableBodyCell = <TData extends MRT_RowData>({
311311
table,
312312
})
313313
) : isCreating || isEditing ? (
314-
<MRT_EditCellTextField
315-
cell={cell}
316-
table={table}
317-
/>
314+
<MRT_EditCellTextField cell={cell} table={table} />
318315
) : showClickToCopyButton && columnDef.enableClickToCopy !== false ? (
319316
<MRT_CopyButton cell={cell} table={table}>
320317
<MRT_TableBodyCellValue {...cellValueProps} />

packages/material-react-table/src/components/buttons/MRT_ToggleRowActionMenuButton.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,11 @@ export const MRT_ToggleRowActionMenuButton = <TData extends MRT_RowData>({
9494
<EditIcon />
9595
</IconButton>
9696
</Tooltip>
97-
) : renderRowActionMenuItems ? (
97+
) : renderRowActionMenuItems?.({
98+
row,
99+
staticRowIndex,
100+
table,
101+
} as any)?.length ? (
98102
<>
99103
<Tooltip {...getCommonTooltipProps()} title={localization.rowActions}>
100104
<IconButton

packages/material-react-table/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1239,7 +1239,7 @@ export interface MRT_TableOptions<TData extends MRT_RowData>
12391239
row: MRT_Row<TData>;
12401240
staticRowIndex?: number;
12411241
table: MRT_TableInstance<TData>;
1242-
}) => ReactNode[];
1242+
}) => ReactNode[] | undefined;
12431243
renderRowActions?: (props: {
12441244
cell: MRT_Cell<TData>;
12451245
row: MRT_Row<TData>;

packages/material-react-table/stories/features/RowActions.stories.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,14 @@ export const RowActionsEnabledConditionally = () => {
128128
};
129129

130130
export const RowActionsEnabledConditionallyPerRow = () => {
131-
const [enabled, setEnabled] = useState(false);
132131
return (
133132
<MaterialReactTable
134133
columns={columns}
135134
data={data}
136-
enableRowActions={enabled}
135+
enableRowActions
137136
renderRowActionMenuItems={({ closeMenu, row }) =>
138137
row.index % 2 === 0
139-
? []
138+
? undefined
140139
: [
141140
<MenuItem
142141
key={1}
@@ -167,9 +166,6 @@ export const RowActionsEnabledConditionallyPerRow = () => {
167166
</MenuItem>,
168167
]
169168
}
170-
renderTopToolbarCustomActions={() => (
171-
<Button onClick={() => setEnabled(!enabled)}>Toggle Row Actions</Button>
172-
)}
173169
/>
174170
);
175171
};

0 commit comments

Comments
 (0)