if (tr == focusedRow) {
insertFirst = true;
} else if (insertFirst) {
+ // remove row explicitly to work around an IE11 bug (#9850)
+ if (BrowserInfo.get().isIE11() && tr
+ .equals(root.getFirstChildElement())) {
+ root.removeChild(tr);
+ }
root.insertFirst(tr);
} else {
root.insertAfter(tr, focusedRow);
--- /dev/null
+package com.vaadin.tests.components.treegrid;
+
+import com.vaadin.data.TreeData;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.TreeGrid;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.Window;
+
+public class TreeGridInWindow extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ TreeGrid<String> treeGrid = new TreeGrid<>();
+ treeGrid.addColumn(Object::toString).setCaption("Column");
+
+ TreeData<String> data = treeGrid.getTreeData();
+
+ data.addRootItems("parent");
+ data.addItems("parent", "child1", "child2");
+ data.addItems("child1", "grandchild1", "grandchild2");
+ data.addItems("child2", "grandchild3", "grandchild4");
+
+ treeGrid.expand("parent", "child1", "child2");
+
+ Window window = new Window("Window", treeGrid);
+
+ Button openWindow = new Button("Open window", event -> {
+ UI.getCurrent().addWindow(window);
+ });
+
+ getLayout().addComponent(openWindow);
+ }
+}
--- /dev/null
+package com.vaadin.tests.components.treegrid;
+
+import org.junit.Test;
+
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.TreeGridElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class TreeGridInWindowTest extends MultiBrowserTest {
+
+ @Test
+ public void collapse_and_expand_first_child_multiple_times() {
+ setDebug(true);
+ openTestURL();
+
+ ButtonElement openWindowButton = $(ButtonElement.class).first();
+ openWindowButton.click();
+
+ TreeGridElement grid = $(TreeGridElement.class).first();
+
+ for (int i = 0; i < 10; i++) {
+ // Collapse first child node
+ grid.getExpandElement(1, 0).click();
+ waitUntil(webDriver -> grid.getRowCount() == 5);
+
+ // Expand first child node
+ grid.getExpandElement(1, 0).click();
+ waitUntil(webDriver -> grid.getRowCount() == 7);
+ }
+
+ assertNoErrorNotifications();
+ }
+}