Search Issue Tracker
By Design
By Design in 2023.2.X
Votes
0
Found in
2021.3.19f1
2022.2.8f1
2023.1.0b5
2023.2.0a3
Issue ID
UUM-27625
Regression
No
ListView commands “itemsAdded” and “itemsSourceChanged” are not called when invoked
How to reproduce:
1. Open the user’s attached “ListViewTest.zip” project
2. Open the “ListViewTestScene” Scene (Assets > UI Docs > ListViewTestScene)
3. Press the “New Items” button and observe the Console window
Expected result: “OnItemsAdded Called Called” and “OnItemsSourceChanged Called” are printed
Actual result: “OnItemsAdded Called Called” and “OnItemsSourceChanged Called” are not printed
Reproducible with: 2021.3.19f1, 2022.2.8f1, 2023.1.0b5, 2023.2.0a3
Could not test with: 2020.3.45f1 (Errors after project downgrade)
Reproduced on: macOS 12.4 (Intel)
Note: ”documentRoot.RegisterCallback<GeometryChangedEvent>” and “listView.RegisterCallback<GeometryChangedEvent>” are printed
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- GameObjects change Hierarchy order when undoing adding Component to multiple GameObjects
- [macOS] Editor crashes after entering Play mode with overlapping GameObjects with Cloth Component and Cloth Inter-Collision enabled
- Look Dev constantly regenerates the default Volume Profile when set to "None" instead of using the default one
- Look Dev errors are spammed when opening a new HDRP project when Look Dev was added to the layout in the previous project
- URP Scene Templates are not editable when first opened from the New Scene dialog
Resolution Note:
This is an issue that was reported on the forums by the user and we resolved it on the forums. For completeness, here is a quote from the thread:
"In the case of the itemsSourceChanged, it doesn't get invoked because for you are setting the listView.itemsSource before registering the callback and the items source does not seem to change afterwards.
In the case of the itemsAdded callback, this is an event that is fired when items are added through the list view directly. In your example, you are manually creating items and adding them to the items source list. You would get the callback if you added items through the list view by using the showAddRemoveFooter for example.
One final note, you should be using OnEnable instead of Awaketo query to rootVisualElement from the UIDocument, as it is not guaranteed to be ready in the Awake call."
Resolution Note (2023.2.X):
This is an issue that was reported on the forums by the user and we resolved it on the forums. For completeness, here is a quote from the thread:
"In the case of the itemsSourceChanged, it doesn't get invoked because for you are setting the listView.itemsSource before registering the callback and the items source does not seem to change afterwards.
In the case of the itemsAdded callback, this is an event that is fired when items are added through the list view directly. In your example, you are manually creating items and adding them to the items source list. You would get the callback if you added items through the list view by using the showAddRemoveFooter for example.
One final note, you should be using OnEnable instead of Awaketo query to rootVisualElement from the UIDocument, as it is not guaranteed to be ready in the Awake call."