Strange Grid behavior

Hi,

I try to build a form with an editor on top of a grid. My grid component extends the MGrid from Viritin and I use the AbstractForm class to build the filedgroup. I also use the way to update a row rather than reload the entire grid container like in the CRUD vaadin archetype. Data is correctly added/updated/removed in the backend but the grid’s behavior is strange whenever the form is visible or not.

When I hide the form when the entry is saved, the first time is OK. However the second time (and other times too), when I click Save in the form, the grid first line is blank and second line is added correctly. Third time same thing, the first line is always blank. When I comment the form.setVisible(false) or form.setEntity(null), the UI is OK. I don’t know what happen but there is a client side exception when I enable the debug mode of Vaadin. I also see a strnge div in html code (see screenshot attached).

The code is also attached. In SureteUI class, try to uncomment line 85 or 86 and run it. Add at least two beans and see the grid strange behavior.

Please take a look. I don’t understand what happens.

Here is the problematic code (looks good to my point of view)

From SureteUI

@Override
protected void init(VaadinRequest vaadinRequest) {
   //...
   bienForm = new BienForm(); //extends AbstractForm
   bienForm.setEntity(null);
   bienForm.setSavedHandler(this::entrySaved);

   bienGrid = new BienGrid2(); // extends MGrid
   //...
}

public void entrySaved(BienEpargne bien) {
    Notification.show("Saved!", Type.HUMANIZED_MESSAGE);
    bienGrid.refresh(bien);
    //cause a client side error
//        bienForm.setVisible(false);  //first line empty
//        bienForm.setEntity(null);    //first line empty
}

From BienGrid2

public void refresh(BienEpargne bien) {
    // We avoid updating the whole table through the backend here so we can
    // get a partial update for the grid
        
    if (getListContainer().containsId(bien)) {
        //Update
        refreshRow(bien);
    } else {
        // New
        getListContainer().addItem(bien);
    }
}

thx
26425.png
26426.zip (61.3 KB)

This is the same issue as described in the following ticket:

https://dev.vaadin.com/ticket/20477