Search Issue Tracker
Fixed
Fixed in 2021.3.36f1, 2022.3.22f1, 2023.2.13f1, 6000.0.0b11
Votes
0
Found in
2021.3.35f1
2022.3.20f1
2023.2.10f1
2023.3.0b5
6000.0.0b11
Issue ID
UUM-64241
Regression
Yes
Error thrown when selecting an item with an empty string in DropdownField
*Steps to reproduce:*
# create an editor window with ui toolkit with the following code:
{code:java}
var newDropdown = new DropdownField
{
choices = new List<string>()
{
"\t",
"1",
"2"
}
}; {code}
2. view the window and select the second item from the dropdown (1)
3. select the first item (renders as an empty string)
*Actual results:*
throws the following error
{code:java}
IndexOutOfRangeException: Index was outside the bounds of the array.
UnityEngine.UIElements.UIElementsUtility.ParseMenuName (System.String menuName) (at <7380b1ba6a1943f8acdb977b1081158a>:0)
UnityEngine.UIElements.PopupField`1[T].GetValueToDisplay () (at <7380b1ba6a1943f8acdb977b1081158a>:0)
UnityEngine.UIElements.BasePopupField`2[TValueType,TValueChoice].SetValueWithoutNotify (TValueType newValue) (at <7380b1ba6a1943f8acdb977b1081158a>:0)
UnityEngine.UIElements.PopupField`1[T].SetValueWithoutNotify (T newValue) (at <7380b1ba6a1943f8acdb977b1081158a>:0)
UnityEngine.UIElements.BaseField`1[TValueType].set_value (TValueType value) (at <7380b1ba6a1943f8acdb977b1081158a>:0)
UnityEngine.UIElements.PopupField`1[T].set_value (T value) (at <7380b1ba6a1943f8acdb977b1081158a>:0)
UnityEngine.UIElements.PopupField`1[T].ChangeValueFromMenu (T menuItem) (at <7380b1ba6a1943f8acdb977b1081158a>:0)
UnityEngine.UIElements.PopupField`1+<>c__DisplayClass27_0[T].<AddMenuItems>b__0 () (at <7380b1ba6a1943f8acdb977b1081158a>:0)
UnityEditor.GenericMenu.CatchMenu (System.Object userData, System.String[] options, System.Int32 selected) (at <c70b76c1ec924538944ac52fdfba807d>:0) {code}
*Expected results:*
no error thrown, item is selected correctly.
From the discussion on slack, it sounds like allowing empty strings of any variety in the list is not allowed. I would expect in that case for this to throw an error much earlier, when setting the choices property. I'd also expect this behavior to be documented somewhere, I'm not seeing it here [https://docs.unity3d.com/Manual/UIE-uxml-element-DropdownField.html]
That said, I don't exactly understand why this design opinion is coming into the api - if a user wants to make a dropdown that is full of empty string, I'm not clear why we would make that impossible at the api level. It makes sense to include it in the design documentation.
*Reproducible with versions:* 2023.3.0b5 (dots monorepo currently)
*Not reproducible with versions:* I'm not sure of the specific version, but this is a regression - I believe the dots monorepo version from november doesn't have this issue.
*Can’t test with versions:*
*Tested on (OS):*
*Notes:*
*
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Inconsistent behaviour when interacting with different dropdown types with pointer events on parent Visual Element
- Hidden GameObjects won't re-enable when they have call "DontDestroyOnLoad" function
- Overlay Canvas are rendered on each split-screen camera when HDR is enabled
- [Android] The Player loses focus when using UnityEngine.Handheld.StartActivityIndicator() with Facebook SDK
- Build fails with "Building Library/Bee/artifacts/MacStandalonePlayerBuildProgram/gahcy/hj9mx3z/951.0 failed with output:..." errors when Scripting Backend is set to IL2CPP
Add comment