I looked into the code and found out Unity updates the css classes of the element when the placeholder changes. This is the workaround that we currently use:
public static class SetValueWithoutNotifyFixedExtentions
{
//This makes sure the placeholder styling actually updates when using SetValueWithoutNotify
//Currently there is a bug in Unity where the placeholder text doesn't update properly when using SetValueWithoutNotify
//If that bug is fixed in future Unity versions, this extension method can be removed
public static void SetValueWithoutNotifyFixed(this TextInputBaseField<string> field, string newValue)
{
field.SetValueWithoutNotify(newValue);
string oldPlaceholder = field.textEdition.placeholder;
field.textEdition.placeholder = "";
field.textEdition.placeholder = oldPlaceholder;
}
}
Actually I am not sure if this is the same bug, because mine is worse. I have object field of type MeshRenderer, I set value without notify to null inside value change callback to avoid triggering callback again, but field goes into weird state, it’s label changes to gray, the icon of mesh renderer hides and actually under the hood the object is not null.
Currently to get correct visual and data state I hack it by setting field without notify, plus binded field: