Fix: position was sometimes reset when the layout changed