TextField.SetValueWithoutNotify doesn't update placeholder style

When I have a TextField with an empty value, it shows a placeholder with light grey color. Then, when I try to set the value without notification:

textField.SetValueWithoutNotify("Some Text");

It changes the text, but it is still shown in the light grey color style instead of white.

Is there any way to fix this?

We are running into the exact same problem.

I was hoping this bugfix: Unity Issue Tracker - TextField placeholder variant USS class is not correctly set when using SetValueWithoutNotify(string.Empty) would fix the issue, but I can confirm the issue still exists in Unity 6000.2.14f1.

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:

rendererObjectField.SetValueWithoutNotify(null);
bindedRenderer = null;

Unity 6000.0.62f1