Skip to content

Grid creates excess rows when items is reassigned #1021

@tomivirkki

Description

@tomivirkki

If the grid's items is assigned with a small array, and then right after reassigned with a large one, you end up with more physical row elements than usually. This can have a negative impact on performance.

A regression from: vaadin/vaadin-grid#2131

Discovered in: vaadin/vaadin-grid-pro#161

A self-contained test-case:

it('should not create excess rows when items is reassigned', () => {
  grid = fixtureSync(`
    <vaadin-grid>
      <vaadin-grid-column path="name"></vaadin-grid-column>>
    </vaadin-grid>
  `);
  grid.items = [{ name: 'item-0' }];
  flushGrid(grid);
  grid.items = Array.from(new Array(100)).map((_, idx) => {
    return { name: `item-${idx}` };
  });

  expect(grid.$.items.childElementCount).to.be.below(26);
});

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions