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
getChildrenByPosition may return wrong results, due to inconsistent _updateTreeOrder tagging.
Note: we don't (and won't) use zIndex and only use "natural" elements order.
Steps to reproduce
TBD. This requires a complex app tree structure which I couldn't reproduce outside of our application.
Expected Behavior
When using stage.getChildrenByPosition, elements are collected using ElementCore.collectAtCoord,
Inside this collection function, the results are sorted (at every step of the recursion!), as a flat list, using ElementCore.sortZIndexedChildren,
This sorting function sorts based on zIndex first, then _updateTreeOrder in case of identical zIndex,
We expect that collected elements are effectively in visible order.
Actual Behavior
_updateTreeOrder isn't always correct (elements on top may have a smaller order index than elements behind), which causes collectAtCoord to sometimes return elements in the wrong order,
even calling explicitly ElementCore.updateTreeOrder before collecting isn't sufficient,
reason may be that both functions (collectAtCoord and updateTreeOrder) do not have identical conditions for skipping/considering elements.
Notes (Optional)
We managed to work around the issue by force re-indexing the elements:
function updateTreeOrder(core: IElementCoreInternal, order: number = 0): number {
core._updateTreeOrder = order++;
if (core._children) {
core._children.forEach((child) => {
order = updateTreeOrder(child, order);
});
}
return order;
}
Invoked as:
updateTreeOrder(stage.root.core);
Just before calling stage.getChildrenByPosition()
The text was updated successfully, but these errors were encountered:
Problem/Opportunity
getChildrenByPosition
may return wrong results, due to inconsistent_updateTreeOrder
tagging.Note: we don't (and won't) use
zIndex
and only use "natural" elements order.Steps to reproduce
TBD. This requires a complex app tree structure which I couldn't reproduce outside of our application.
Expected Behavior
stage.getChildrenByPosition
, elements are collected usingElementCore.collectAtCoord
,ElementCore.sortZIndexedChildren
,zIndex
first, then_updateTreeOrder
in case of identicalzIndex
,Actual Behavior
_updateTreeOrder
isn't always correct (elements on top may have a smaller order index than elements behind), which causescollectAtCoord
to sometimes return elements in the wrong order,ElementCore.updateTreeOrder
before collecting isn't sufficient,collectAtCoord
andupdateTreeOrder
) do not have identical conditions for skipping/considering elements.Notes (Optional)
We managed to work around the issue by force re-indexing the elements:
Invoked as:
Just before calling
stage.getChildrenByPosition()
The text was updated successfully, but these errors were encountered: