Search Issue Tracker
Fixed
Fixed in 2021.3.36f1, 2022.3.22f1, 2023.2.13f1, 2023.3.0b11
Votes
0
Found in
2021.3.35f1
2022.3.20f1
2023.2.10f1
2023.3.0b5
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
- “[Worker0] Could not generate preview image“ error when opening macOS native plugin in the Inspector with Architecture to build for set to ARM 64-bit
- [iOS] Application.absoluteURL is empty on Awake/Start when opening via deep link with Splash Screen disabled
- Crash on MemoryManager::Deallocate when rapidly calling Addressables.LoadAssetAsync
- Crash on physx::shdfnd::atomicIncrement when adjusting values on a character controller component after entering Play mode in Prefab edit mode
- [Rendering Debugger] [NewInputSystem] Debug Overlays in Play mode throws InvalidOperationException when using New Input System
Add comment