Skip to content

Commit

Permalink
chore: removla of wrong spreaded values of tablecell
Browse files Browse the repository at this point in the history
  • Loading branch information
Domino987 committed Jul 2, 2021
1 parent 72c5c1b commit b4b04c6
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/components/MTableCell/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,32 @@ import { getRenderValue, getStyle } from './utils';
/* eslint-enable no-unused-vars */

function MTableCell(props) {
const {
forwardedRef,
scrollWidth,
rowData,
onCellEditStarted,
cellEditable,
columnDef,
errorState,
...spreadProps
} = props;
const handleClickCell = (e) => {
if (props.columnDef.disableClick) {
e.stopPropagation();
}
};

const cellAlignment =
props.columnDef.align !== undefined
? props.columnDef.align
: ['numeric', 'currency'].indexOf(props.columnDef.type) !== -1
columnDef.align !== undefined
? columnDef.align
: ['numeric', 'currency'].indexOf(columnDef.type) !== -1
? 'right'
: 'left';

let renderValue = getRenderValue(props);

if (props.cellEditable) {
if (cellEditable) {
renderValue = (
<div
style={{
Expand All @@ -31,7 +41,7 @@ function MTableCell(props) {
}}
onClick={(e) => {
e.stopPropagation();
props.onCellEditStarted(props.rowData, props.columnDef);
onCellEditStarted(rowData, columnDef);
}}
>
{renderValue}
Expand All @@ -41,13 +51,13 @@ function MTableCell(props) {

return (
<TableCell
{...props}
{...spreadProps}
size={props.size}
value={props.value}
style={getStyle(props)}
align={cellAlignment}
onClick={handleClickCell}
ref={props.forwardedRef}
ref={forwardedRef}
colSpan={props.colSpan}
>
{props.children}
Expand Down

0 comments on commit b4b04c6

Please sign in to comment.