@@ -8,7 +8,7 @@ import _ from './utils';
88class Cell extends eventDelegater ( Component ) {
99 constructor ( props ) {
1010 super ( props ) ;
11- this . handleEditingCell = this . handleEditingCell . bind ( this ) ;
11+ this . createHandleEditingCell = this . createHandleEditingCell . bind ( this ) ;
1212 }
1313
1414 shouldComponentUpdate ( nextProps ) {
@@ -43,17 +43,10 @@ class Cell extends eventDelegater(Component) {
4343 return shouldUpdate ;
4444 }
4545
46- handleEditingCell ( e ) {
47- const { column, onStart, rowIndex, columnIndex, clickToEdit, dbclickToEdit } = this . props ;
48- const { events } = column ;
49- if ( events ) {
50- if ( clickToEdit ) {
51- const customClick = events . onClick ;
52- if ( _ . isFunction ( customClick ) ) customClick ( e ) ;
53- } else if ( dbclickToEdit ) {
54- const customDbClick = events . onDoubleClick ;
55- if ( _ . isFunction ( customDbClick ) ) customDbClick ( e ) ;
56- }
46+ createHandleEditingCell = originFunc => ( e ) => {
47+ const { onStart, rowIndex, columnIndex, clickToEdit, dbclickToEdit } = this . props ;
48+ if ( ( clickToEdit || dbclickToEdit ) && _ . isFunction ( originFunc ) ) {
49+ originFunc ( e ) ;
5750 }
5851 if ( onStart ) {
5952 onStart ( rowIndex , columnIndex ) ;
@@ -85,9 +78,9 @@ class Cell extends eventDelegater(Component) {
8578 }
8679
8780 if ( clickToEdit && editable ) {
88- attrs . onClick = this . handleEditingCell ;
81+ attrs . onClick = this . createHandleEditingCell ( attrs . onClick ) ;
8982 } else if ( dbclickToEdit && editable ) {
90- attrs . onDoubleClick = this . handleEditingCell ;
83+ attrs . onDoubleClick = this . createHandleEditingCell ( attrs . onDoubleClick ) ;
9184 }
9285
9386 return (
0 commit comments