Skip to content

Commit

Permalink
Merge pull request mbrn#2313 from mbrn/onBulkEditRowChanged
Browse files Browse the repository at this point in the history
Removal of onBulkEditRowChanged from spreaded props
  • Loading branch information
mbrn authored Aug 16, 2020
2 parents 666cfb8 + 720440a commit 669ca4a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
23 changes: 12 additions & 11 deletions demo/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,9 +539,10 @@ class App extends Component {
new Promise((resolve, reject) => {
setTimeout(() => {
{
/* const data = this.state.data;
data.push(newData);
this.setState({ data }, () => resolve()); */
/*
const data = [...this.state.data, newData];
this.setState({ data }, () => resolve());
*/
}
resolve();
}, 1000);
Expand All @@ -550,10 +551,10 @@ class App extends Component {
new Promise((resolve, reject) => {
setTimeout(() => {
{
/* const data = this.state.data;
const index = data.indexOf(oldData);
data[index] = newData;
this.setState({ data }, () => resolve()); */
/*
const data = this.state.data.filter(d => d !== oldData);
this.setState({ data: [...data, newData] }, () => resolve());
*/
}
resolve();
}, 1000);
Expand All @@ -562,10 +563,10 @@ class App extends Component {
new Promise((resolve, reject) => {
setTimeout(() => {
{
/* let data = this.state.data;
const index = data.indexOf(oldData);
data.splice(index, 1);
this.setState({ data }, () => resolve()); */
/*
const data = this.state.data.filter(d => d !== oldData);
this.setState({ data }, () => resolve());
*/
}
resolve();
}, 1000);
Expand Down
1 change: 1 addition & 0 deletions src/components/m-table-edit-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class MTableEditField extends React.Component {
rowData,
onRowDataChange,
errorState,
onBulkEditRowChanged,
...props
} = this.props;
return props;
Expand Down
17 changes: 11 additions & 6 deletions src/components/m-table-edit-row.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,18 @@ export default class MTableEditRow extends React.Component {
const data = { ...this.state.data };
setByString(data, columnDef.field, value);
// data[columnDef.field] = value;
this.setState({ data }, () =>
this.props.onBulkEditRowChanged(this.props.data, data)
);
this.setState({ data }, () => {
if (this.props.onBulkEditRowChanged) {
this.props.onBulkEditRowChanged(this.props.data, data);
}
});
}}
onRowDataChange={(data) => {
this.setState({ data }, () =>
this.props.onBulkEditRowChanged(this.props.data, data)
);
this.setState({ data }, () => {
if (this.props.onBulkEditRowChanged) {
this.props.onBulkEditRowChanged(this.props.data, data);
}
});
}}
/>
</TableCell>
Expand Down Expand Up @@ -355,6 +359,7 @@ export default class MTableEditRow extends React.Component {
options,
actions,
errorState,
onBulkEditRowChanged,
...rowProps
} = this.props;

Expand Down

0 comments on commit 669ca4a

Please sign in to comment.