ChangeEvent behaviour, bug or design choice?

Hi
I have a Foldout that has a Toggle child down its ContentContainer hierarchy.

Now when I register a ChangeEvent callback to foldout it is raised not only when I click on a foldout but also when I click on the previously mentioned toggle.

It is a bug? I filed a bug report but got no response.

        var root = rootVisualElement;
        var foldout = new Foldout();
        foldout.RegisterValueChangedCallback(e=>Debug.Log("Change"));
       
        var toggle = new Toggle();
        foldout.Add(toggle);
        root.Add(foldout);

Yes, this seems like a bug. We got the report that you filed, thank you!

ChangeEvent that are sent to an element will propagate up the tree. In this case, the toggle change event bubbles up to the foldout. I agree that this behavior is not what’s expected in that case. Until we fix this, you can change your code to:

foldout.RegisterValueChangedCallback(e=> if(e.target == foldout) Debug.Log("Change"));