|
1 | 1 | import { expect } from '@esm-bundle/chai'; |
2 | 2 | import { aTimeout, fixtureSync } from '@vaadin/testing-helpers'; |
| 3 | +import '../vaadin-grid-sort-column.js'; |
3 | 4 | import '../vaadin-grid.js'; |
4 | 5 | import { html, render } from 'lit'; |
5 | 6 | import { getPhysicalItems } from './helpers.js'; |
@@ -32,4 +33,31 @@ describe('lit', () => { |
32 | 33 | const grid = wrapper.firstElementChild; |
33 | 34 | expect(getPhysicalItems(grid).length).to.equal(1); |
34 | 35 | }); |
| 36 | + |
| 37 | + it('should not throw when dynamically removing sort columns after sorting', async () => { |
| 38 | + const wrapper = fixtureSync(`<div></div>`); |
| 39 | + |
| 40 | + function renderGrid(columnPaths, items) { |
| 41 | + render( |
| 42 | + html` |
| 43 | + <vaadin-grid .items=${items}> |
| 44 | + ${columnPaths.map((columnPath) => { |
| 45 | + return html`<vaadin-grid-sort-column path="${columnPath}"></vaadin-grid-sort-column>`; |
| 46 | + })} |
| 47 | + </vaadin-grid> |
| 48 | + `, |
| 49 | + wrapper, |
| 50 | + ); |
| 51 | + } |
| 52 | + |
| 53 | + // First render with two columns |
| 54 | + renderGrid(['c1', 'c2'], [{ c1: '1-1', c2: '1-2' }]); |
| 55 | + |
| 56 | + await aTimeout(0); |
| 57 | + |
| 58 | + document.querySelector('vaadin-grid-sorter').click(); |
| 59 | + |
| 60 | + // Then render a grid with one column |
| 61 | + renderGrid(['c1'], [{ c1: '1-1', c2: '1-2' }]); |
| 62 | + }); |
35 | 63 | }); |
0 commit comments