You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Removing an element after its children are moved to be siblings fails on client side #11983
// Open following element hierarchyElementcontainer = ElementFactory.createDiv();
Elementwrapper = ElementFactory.createDiv();
Elementfirst = ElementFactory.createDiv();
Elementsecond = ElementFactory.createDiv();
container.add(wrapper);
wrapper.add(first, second);
Elementbutton = ElementFactore.createButton();
button.setText("Click me");
add(container, button);
// Then later on click the button, executing the following codebutton.addListener("click", event -> {
container.appendChild(wrapper.getChildren().toArray(Element[]::new));
wrapper.removeFromParent();
});
Expected
The children of the wrapper are moved one layer up and wrapper itself is removed.
Actual
Client side error with
(NotFoundError) : Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.
The issue is caused by the fact that the children are not detached.
As a result the clean up code which is executed for detached nodes is not executed.
Such clean up code unregisters a StateNode on the client side from a StateTree and when the Element on the server side is reattached back the StateNode is completely recreated and rebound.
In the described scenario the moved StateNode child keeps the DomNode whose parent is a removed node.
Activity
fix: reset Dom node on changing StateNode parent
fix: reset Dom node on changing StateNode parent
fix: reset Dom node on changing StateNode parent (#12043)
fix: reset Dom node on changing StateNode parent (#12043)
fix: reset Dom node on changing StateNode parent (#12043)
fix: reset Dom node on changing StateNode parent (#12043) (#12101)
fix: reset Dom node on changing StateNode parent (#12043) (#12102)
3 remaining items
denis-anisimov commentedon Oct 22, 2021
The issue is caused by the fact that the children are not detached.
As a result the clean up code which is executed for detached nodes is not executed.
Such clean up code unregisters a
StateNodeon the client side from aStateTreeand when theElementon the server side is reattached back theStateNodeis completely recreated and rebound.In the described scenario the moved
StateNodechild keeps theDomNodewhose parent is a removed node.I've tried to fix that via removing
DomNodeonsetParentcall (so when theStateNodeis moved it should be rebound with a new DOM Node which emulate reataching).But it looks like there is some scenario which relies on the behavior of preserving DOM node when a new parent is set.
It might be that this is a case of virtual child but it's absolutely unclear what's exactly broken.
The broken scenario is : https://github.com/vaadin/flow-components/blob/master/vaadin-grid-flow-parent/vaadin-grid-flow-integration-tests/src/test/java/com/vaadin/flow/component/grid/it/GridHeaderFooterRowIT.java#L295
(some test in Grid).
Revert "fix: reset Dom node on changing StateNode parent (#12043)" (#…
vaadin-bot commentedon Nov 8, 2021
This ticket/PR has been released with platform 14.7.4.
vaadin-bot commentedon Nov 8, 2021
This ticket/PR has been released with platform 21.0.4.
vaadin-bot commentedon Nov 22, 2021
This ticket/PR has been released with platform 21.0.7.