Search Issue Tracker

By Design

Votes

0

Found in

2022.3.8f1

2023.1.10f1

2023.2.0b6

2023.3.0a2

Issue ID

UUM-46857

Regression

No

RegisterValueChangedCallback raised for parent element when it is raised for child if they both use it

--

-

Reproduction steps:
1. Open the attached project "Bug-INotifyValueChanged"
2. Click "Tests/INotifyValueChanged Bug Window" in the menu bar
3. Expand the "Foldout" in the TestWindow
4. Click the "Value" checkbox in the TestWindow

Expected result: The Console logs "Foldout 'ValueChanged' raised with value: True" and "Toggle 'ValueChanged' raised with value: True"
Actual result: The Console logs: "Foldout 'ValueChanged' raised with value: True", "Toggle 'ValueChanged' raised with value: True" and "Foldout 'ValueChanged' raised with value: True"

Reproducible with: 2021.3.29f1, 2022.3.8f1, 2023.1.10f1, 2023.2.0b6, 2023.3.0a2

Reproducible on: macOS 13.4.1 (Intel), Windows 10 (user’s)
Not reproducible on: No other environment tested

Note: not reproducible if not using RegisterValueChangedCallback with the "Foldout" - comment lines 23-28 of TestWindow.cs

  1. Resolution Note:

    As can be seen on the Unity Manual, the ChangeEvent event bubbles and trickles down, so it will reach parent elements after the child element:
    https://docs.unity3d.com/Manual/UIE-Change-Events.html

    You can add `evt.StopPropagation()` at the end of the Toggle callback to stop it from reaching the parent and obtain the expected behavior.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.