@@ -6,6 +6,7 @@ import { HotColumn } from './hotColumn';
6
6
import * as packageJson from '../package.json' ;
7
7
import { HotTableProps } from './types' ;
8
8
import {
9
+ AUTOSIZE_WARNING ,
9
10
createEditorPortal ,
10
11
createPortal ,
11
12
getChildElementByType ,
@@ -14,6 +15,7 @@ import {
14
15
addUnsafePrefixes ,
15
16
removeEditorContainers
16
17
} from './helpers' ;
18
+ import { warn } from 'handsontable/commonjs/helpers/console' ;
17
19
18
20
/**
19
21
* A Handsontable-ReactJS wrapper.
@@ -113,6 +115,15 @@ class HotTable extends React.Component<HotTableProps, {}> {
113
115
*/
114
116
private editorCache : Map < string , React . Component > = new Map ( ) ;
115
117
118
+ /**
119
+ * Map with column indexes (or a string = 'global') as keys, and booleans as values. Each key represents a component-based editor
120
+ * declared for the used column index, or a global one, if the key is the `global` string.
121
+ *
122
+ * @private
123
+ * @type {Map }
124
+ */
125
+ private componentRendererColumns : Map < number | string , boolean > = new Map ( ) ;
126
+
116
127
/**
117
128
* Package version getter.
118
129
*
@@ -169,6 +180,8 @@ class HotTable extends React.Component<HotTableProps, {}> {
169
180
removeEditorContainers ( this . hotElementRef ? this . hotElementRef . ownerDocument : document ) ;
170
181
171
182
renderedCellCache . clear ( ) ;
183
+
184
+ this . componentRendererColumns . clear ( ) ;
172
185
}
173
186
174
187
/**
@@ -336,14 +349,15 @@ class HotTable extends React.Component<HotTableProps, {}> {
336
349
newSettings . editor = this . getEditorClass ( globalEditorNode ) ;
337
350
338
351
} else {
339
- newSettings . editor = this . props . editor || this . props . settings ? this . props . settings . editor : void 0 ;
352
+ newSettings . editor = this . props . editor || ( this . props . settings ? this . props . settings . editor : void 0 ) ;
340
353
}
341
354
342
355
if ( globalRendererNode ) {
343
356
newSettings . renderer = this . getRendererWrapper ( globalRendererNode ) ;
357
+ this . componentRendererColumns . set ( 'global' , true ) ;
344
358
345
359
} else {
346
- newSettings . renderer = this . props . renderer || this . props . settings ? this . props . settings . renderer : void 0 ;
360
+ newSettings . renderer = this . props . renderer || ( this . props . settings ? this . props . settings . renderer : void 0 ) ;
347
361
}
348
362
349
363
return newSettings ;
@@ -356,32 +370,8 @@ class HotTable extends React.Component<HotTableProps, {}> {
356
370
*/
357
371
displayAutoSizeWarning ( newGlobalSettings : Handsontable . GridSettings ) : void {
358
372
if ( this . hotInstance . getPlugin ( 'autoRowSize' ) . enabled || this . hotInstance . getPlugin ( 'autoColumnSize' ) . enabled ) {
359
- const isNativeRenderer = ( renderer , column ?) => {
360
- const standaloneColumnRenderer = this . props . columns && this . props . columns [ column ] ? this . props . columns [ column ] . renderer : null ;
361
- const settingsObjectColumnRenderer = this . props . settings && this . props . settings . columns && this . props . settings . columns [ column ] ? this . props . settings . columns [ column ] . renderer : null ;
362
-
363
- return column ?
364
- standaloneColumnRenderer === renderer || settingsObjectColumnRenderer === renderer :
365
- this . props . renderer === renderer || this . props . settings . renderer === renderer ;
366
- } ;
367
- let rendererDefined = false ;
368
-
369
- if ( newGlobalSettings . renderer && ! isNativeRenderer ( newGlobalSettings . renderer ) ) {
370
- rendererDefined = true ;
371
- }
372
-
373
- if ( ! rendererDefined && newGlobalSettings . columns ) {
374
- for ( let i = 0 ; i < newGlobalSettings . columns . length ; i ++ ) {
375
- if ( newGlobalSettings . columns [ i ] . renderer && ! isNativeRenderer ( newGlobalSettings . columns [ i ] . renderer , i ) ) {
376
- rendererDefined = true ;
377
- break ;
378
- }
379
- }
380
- }
381
-
382
- if ( rendererDefined ) {
383
- console . warn ( 'Your `HotTable` configuration includes `autoRowSize`/`autoColumnSize` options, which are not compatible with ' +
384
- ' the component-based renderers`. Disable `autoRowSize` and `autoColumnSize` to prevent row and column misalignment.' ) ;
373
+ if ( this . componentRendererColumns . size > 0 ) {
374
+ warn ( AUTOSIZE_WARNING ) ;
385
375
}
386
376
}
387
377
}
@@ -513,6 +503,7 @@ class HotTable extends React.Component<HotTableProps, {}> {
513
503
// clone the HotColumn nodes and extend them with the callbacks
514
504
let childClones = children . map ( ( childNode : React . ReactElement , columnIndex : number ) => {
515
505
return React . cloneElement ( childNode , {
506
+ _componentRendererColumns : this . componentRendererColumns ,
516
507
_emitColumnSettings : this . setHotColumnSettings . bind ( this ) ,
517
508
_columnIndex : columnIndex ,
518
509
_getChildElementByType : getChildElementByType . bind ( this ) ,
0 commit comments