Search Issue Tracker

By Design

Votes

0

Found in

2021.3.35f1

2022.3.19f1

2023.2.9f1

2023.3.0b6

Issue ID

UUM-63217

Regression

No

Random amount of elements are added to the ListView when pressing the + button if having a custom ListView

--

-

How to reproduce:
1. Open the user’s attached “BugReport.zip” project
2. In the Hierarchy window, select “Test01” GameObject
3. In the Inspector window, press the + button in the “Bug Report 01” Component
4. Observe the list

Expected result: 2 elements are in the list
Actual result: 3 elements are in the list

Reproducible with: 2021.3.35f1, 2022.3.19f1, 2023.2.9f1, 2023.3.0b6

Reproduced on: macOS 14.2.1 (Intel)
Not reproducible on: No other environment tested

Notes:
- not reproducible after deselecting and selecting “Test01” GameObject
- the same issue happens when entering a number in the value field

  1. Resolution Note:

    The problem lies in the provided project's code. They use bindItem to add the content instead of only binding existing elements. They should be using makeItem for element creation, and bindItem to assign values. BindItem is called multiple times as items are virtualized by the ListView, so adding elements there is not recommended, or should be reverted by a unbindItem or covered by null checks.

    For more information, see https://docs.unity3d.com/Manual/UIE-ListView-TreeView.html

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.