boolean newOrUpdatedDetails = refreshRange(availableAndVisible);
+ // the update may have affected details row contents and size,
+ // recalculation and triggering of any pending navigation
+ // confirmations etc. is needed
+ triggerDelayedRepositioning(availableAndVisible.getStart(),
+ availableAndVisible.length());
+
markDetailsAddedOrUpdatedForDelayedAlertToGrid(newOrUpdatedDetails);
}
}
mainLayout.addComponent(grid);
- Button clickButton = new Button("Change items", event -> {
+ Button changeButton1 = new Button("Change with details", event -> {
List<Collection<String>> itemsOverwrite = Arrays
.asList(secondCollection, fourthCollection);
grid.setItems(itemsOverwrite);
grid.setDetailsVisible(tmp, true);
}
});
- mainLayout.addComponent(clickButton);
+ mainLayout.addComponent(changeButton1);
+ Button changeButton2 = new Button("Change without details", event -> {
+ List<Collection<String>> itemsOverwrite = Arrays
+ .asList(secondCollection, fourthCollection);
+ grid.setItems(itemsOverwrite);
+ });
+ mainLayout.addComponent(changeButton2);
return mainLayout;
}
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.number.IsCloseTo.closeTo;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import org.junit.Test;
+import org.openqa.selenium.By;
import com.vaadin.testbench.TestBenchElement;
import com.vaadin.testbench.elements.ButtonElement;
public void testDetailsUpdateWithItems() {
openTestURL();
GridElement grid = $(GridElement.class).first();
- ButtonElement button = $(ButtonElement.class).first();
+ ButtonElement button = $(ButtonElement.class)
+ .caption("Change with details").first();
String details0 = grid.getDetails(0).getText();
assertDirectlyAbove(cell1_0, detailCell1);
}
+ @Test
+ public void testRemovingDetailsWithItemUpdateRepositionsRowsCorrectly() {
+ openTestURL();
+ GridElement grid = $(GridElement.class).first();
+ ButtonElement button = $(ButtonElement.class)
+ .caption("Change without details").first();
+
+ assertFalse("Details not found when there should be some.",
+ grid.findElements(By.className("v-grid-spacer")).isEmpty());
+
+ // change the contents
+ button.click();
+
+ waitForElementNotPresent(By.className("v-grid-spacer"));
+
+ GridCellElement cell0_0 = grid.getCell(0, 0);
+ GridCellElement cell1_0 = grid.getCell(1, 0);
+
+ // ensure positioning is correct
+ assertDirectlyAbove(cell0_0, cell1_0);
+ }
+
private void assertDirectlyAbove(TestBenchElement above,
TestBenchElement below) {
int aboveBottom = above.getLocation().getY()