Skip to content

vaadin 14.13.0 grid invisible items bug #7623

@Robrecht-p

Description

@Robrecht-p

Description

When upgrading from vaadin 14.12.0 to 14.13.0, strange issues consistently show up in certain grids in dialogs where code was not altered. Not all grids seem to be affected, only specific ones always have the same issue when closing and re-opening the same dialog. I wrote some pseudo code to show you my general way of working where grids are breaking. However, I can not seem to understand at all why some grids are affected and some of them are not.

Like I describe below, when you close the dialog and open it again, then the grid is now broken and produces an error in the Chrome console:

main:2 There seems to be an error in the Vaadin Grid:
Cannot read properties of undefined (reading '0')

Additional info based on some feedback from Tatu:
SomeClass POJO: it happens with simple java objects as data object in the grid. Nothing special here, it just holds some data and it is visualised.
Polymer template: I only ever use Polymer templates. The actual grid is defined as HTML in the .js files. It happens in very simple components holding almost only a grid (+ some header text for example), so should be reproducable with just a grid.
SomeView missing button: I dont think there is any relevance on how it is actually triggered. It always starts from a user interaction, in practice clicking a simple button that is likewise defined in the HTML and a click listener added to in java.
Spring: When adding components to dialogs, I always inject them using spring and them to a dialog like this. I dont think it would be very relevant whether it is spring or just a new vaadin objects constructed yourself.

Expected outcome

The grid does not break and shows like it is supposed to, like in all previous versions.

Minimal reproducible example



//js file of the component, very plain just containing a grid
class SomeComponent extends PolymerElement {

    static get template() {
        return html`
            <style include="shared-styles">
                :host {
                    display: block;
                    height: 100%;
                }
            </style>
<vaadin-vertical-layout>
    <vaadin-grid id=grid></vaadin-grid>
</vaadin-vertical-layout>
        `;
    }

    static get is() {
        return 'some-component';
    }

    static get properties() {
        return {
           
        };
    }
}

customElements.define(SomeComponent.is, SomeComponent);
//end of js file


//component with a breaking grid:
@Tag("some-component")
@JsModule("./src/components/some-component.js")
@SpringComponent
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class SomeComponent extends PolymerTemplate<SomeComponentModel> {

    @Id("grid") //grid is defined in the js file
    private Grid<SomeClass> grid;

    protected final ListDataProvider<SomeClass> provider = DataProvider.ofCollection(new ArrayList<>());


   public SomeComponent() {
     //it seems to happen with multiple grids, some are really simple like this, some are using TemplateRenderer.of(<htmlCode>)
       grid.addColumn(SomeClass::getName);
   }

   public void clear() { //clear all data
      provider.getItems().clear();
      provider.refreshAll();
   }

   public void addData(SomeClass some) { //example of adding some data to provider
      provider.getItems().add(some);
      provider.refreshAll();
   }


    public interface SomeComponentModel extends TemplateModel {
        //nothing interesting here
    }
}


//a simple view containing above component in a dialog

@Tag("some-view")
@JsModule("./src/views/some-view.js")
@Route(value = someRoute)
public class SomeView extends extends PolymerTemplate<SomeViewModel> {

  private final SomeComponent component;

   Dialog dialog = new Dialog();

   @AutoWired
   public someView(SomeComponent component) {
      this.component = component,
      dialog.add(component);
   }

//imagine user can call this methods using a button or something
  public void open() {
      dialog.open();
      component.addData(someData);
   }

   public void close() {
      component.clear();
      dialog.close();
   }

    public interface SomeViewModel extends TemplateModel {
        //nothing interesting here
    }
}

Steps to reproduce

  1. open the view
  2. open the dialog, some data is added to the grid. This works fine
  3. Close the dialog. The bug only seems to occur when the dataprovider is actually emptied around closing time
  4. open the dialog again, some data is added. Now the dialog is broken, not correctly showing data and producing the console error

Environment

Vaadin version(s): 14.13.0
OS: Windows (local), linux containers (test/production environments)

Browsers

Chrome, Edge

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions