Input Field inside a Scroll Rect doesn't resize the container.

Please, I am getting crazy.

I have:

Scroll View

→ Viewport

-----> Content 97336-screen-shot-2017-07-08-at-141228.png

--------> Dynamic Input Field

--------> Static Text

--------> Static Text

--------> Static Text

Resulting Behaviour:

Fine if the text is getting shorter.
Bad is the text is getting longer: the dynamic input field content is overlapped by the static texts.
NOTE: The text is inserted through code. If I insert it manually into the Input Field everything works fine.

My idea is that it needs to be redrawn, because the same behaviour happens in the editor but when I do something that update the scene view then it resizes correctly.

This is how I resolved it. It looks kind of ugly but it works perfectly.

void Awake ()
{
        inputField.text  = myRandomText;
        StartCoroutine(ForceContainerToRecalculateLayout());
}

private IEnumerator ForceContainerToRecalculateLayout ()
{
		yield return new WaitForEndOfFrame ();
		container.GetComponent<VerticalLayoutGroup>().childForceExpandHeight = false;
		yield return new WaitForEndOfFrame ();
		container.GetComponent<VerticalLayoutGroup> ().childForceExpandHeight = true;
}