Layout not updating when TMP Input Field under a layout group is modified

Unity 2021.1.7f1, TMP 3.0.6
Should be reproable in other Unity versions too

1. Add a TMP Input Field to a scene
2. Move it under a parent object that has a HorizontalLayoutGroup
3. Enable only the "Control Child Size: Width" option
4. Edit the text in the input field
What I expect: The width of the input field rect transform increases to match the preferred width driven by the parent layout group
What happened: The width stays the same and only updates if the parent layout group is updated by e.g. deactivating and activating it

I investigated the source code of TMP_InputField and found the cause to be a failure to call LayoutRebuilder.MarkLayoutForRebuild in Scripts\Runtime\TMP_InputField.cs:3253 if the game object does not have a ILayoutController component attached. In reality the parent controller should also be taken into account. m_IsDrivenByLayoutComponents seems like an unnecessary optimization that causes this bug as MarkLayoutForRebuild is already optimized internally.

1 Like

Same issue here, until a sibling is added or removed the layout is not updating on TMP Input Field edit