Fixed inverted logic to correctly recalculate layout even when the layout has been recalculated previously in the same frame