File tree Expand file tree Collapse file tree 2 files changed +52
-1
lines changed Expand file tree Collapse file tree 2 files changed +52
-1
lines changed Original file line number Diff line number Diff line change 322
322
}
323
323
324
324
cells . forEach ( cell => {
325
- const model = this . _grid . __getRowModel ( cell . parentElement ) ;
325
+ const parent = cell . parentElement ;
326
+
327
+ // When a column is made hidden and shown again, in some instances it breaks rendering of rows for grid
328
+ // this happens when parent element of cell is null, which might not be set correctly during rendering
329
+ // the newly shown column, this check simply avoid that case
330
+ if ( ! parent ) {
331
+ return ;
332
+ }
333
+ const model = this . _grid . __getRowModel ( parent ) ;
326
334
327
335
if ( renderer ) {
328
336
cell . _renderer = renderer ;
Original file line number Diff line number Diff line change 70
70
</ template >
71
71
</ test-fixture >
72
72
73
+ < test-fixture id ="grid-with-external-filter ">
74
+ < template >
75
+ < vaadin-grid >
76
+ < vaadin-grid-column path ="first "> </ vaadin-grid-column >
77
+ < vaadin-grid-column id ="last " path ="last "> </ vaadin-grid-column >
78
+ </ vaadin-grid >
79
+ </ template >
80
+ </ test-fixture >
81
+
73
82
< script >
74
83
75
84
describe ( 'filter' , ( ) => {
331
340
} ) ;
332
341
333
342
} ) ;
343
+
344
+ describe ( 'in-memory filtering and hiding a column' , ( ) => {
345
+ it ( 'should correctly display items after filter is cleared and column is made visible' , ( ) => {
346
+ const grid = fixture ( 'grid-with-external-filter' ) ;
347
+ const column = grid . querySelector ( '#last' ) ;
348
+ // this is the minimum amount of items that should be in data-provider in order to see the bug
349
+ const itemCount = 56 ;
350
+ const items = Array . apply ( null , Array ( itemCount ) ) . map ( ( _ , i ) => {
351
+ return {
352
+ first : 'foo' + i ,
353
+ last : 'bar' + i
354
+ } ;
355
+ } ) ;
356
+ grid . items = items ;
357
+ flushGrid ( grid ) ;
358
+
359
+ // filter the data and hide one column
360
+ column . hidden = true ;
361
+ grid . items = items . filter ( item => item . first === 'foo55' ) ;
362
+ flushGrid ( grid ) ;
363
+
364
+ // clear filter and show column again
365
+ column . hidden = false ;
366
+ grid . items = items ;
367
+ flushGrid ( grid ) ;
368
+
369
+ // get cell content of 5th row and check if it is displayed correctly
370
+ const bodyRows = getRows ( grid . $ . items ) ;
371
+ const rowCells = getRowCells ( bodyRows [ 5 ] ) ;
372
+ const cellContent = getCellContent ( rowCells [ 1 ] ) . textContent ;
373
+
374
+ expect ( cellContent ) . to . be . equal ( 'bar5' ) ;
375
+ } ) ;
376
+ } ) ;
334
377
</ script >
335
378
336
379
</ body >
You can’t perform that action at this time.
0 commit comments