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
- Texture2D hash changes inside of an AssetBundle when rebuilding a SpriteAtlas bundle with an empty AssetPostprocessor Script enabled
- Aniso Level still applies when Generate MipMap is disabled in Texture Import Settings
- Mipmap Limit Groups long names are not truncated when creating a new Mipmap Limit Group with a long name
- “ArgumentException: Invalid double parameter.” error is thrown when Infinity is typed into the Fixed Timestep field
- GameObject becomes gray when using HDRP and STP together on macOS
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."