Fix colour swap for stack component

Selecting a group changes display order of SVG elements.
We now ensure that the element order is correct on re-render.