From 6168bd7532524edfa8d59b034bbccd5f7328ca55 Mon Sep 17 00:00:00 2001 From: AllenFang Date: Sat, 27 Apr 2019 16:11:55 +0800 Subject: [PATCH] fix #905 --- packages/react-bootstrap-table2/src/cell.js | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/packages/react-bootstrap-table2/src/cell.js b/packages/react-bootstrap-table2/src/cell.js index ba1e551..c3684bd 100644 --- a/packages/react-bootstrap-table2/src/cell.js +++ b/packages/react-bootstrap-table2/src/cell.js @@ -8,7 +8,7 @@ import _ from './utils'; class Cell extends eventDelegater(Component) { constructor(props) { super(props); - this.handleEditingCell = this.handleEditingCell.bind(this); + this.createHandleEditingCell = this.createHandleEditingCell.bind(this); } shouldComponentUpdate(nextProps) { @@ -43,17 +43,10 @@ class Cell extends eventDelegater(Component) { return shouldUpdate; } - handleEditingCell(e) { - const { column, onStart, rowIndex, columnIndex, clickToEdit, dbclickToEdit } = this.props; - const { events } = column; - if (events) { - if (clickToEdit) { - const customClick = events.onClick; - if (_.isFunction(customClick)) customClick(e); - } else if (dbclickToEdit) { - const customDbClick = events.onDoubleClick; - if (_.isFunction(customDbClick)) customDbClick(e); - } + createHandleEditingCell = originFunc => (e) => { + const { onStart, rowIndex, columnIndex, clickToEdit, dbclickToEdit } = this.props; + if ((clickToEdit || dbclickToEdit) && _.isFunction(originFunc)) { + originFunc(e); } if (onStart) { onStart(rowIndex, columnIndex); @@ -85,9 +78,9 @@ class Cell extends eventDelegater(Component) { } if (clickToEdit && editable) { - attrs.onClick = this.handleEditingCell; + attrs.onClick = this.createHandleEditingCell(attrs.onClick); } else if (dbclickToEdit && editable) { - attrs.onDoubleClick = this.handleEditingCell; + attrs.onDoubleClick = this.createHandleEditingCell(attrs.onDoubleClick); } return (