Steps to reproduce:
- Create a new 3D URP project
- Create a new UXML Document and open it (Assets > Create > UI Toolkit > UI Document)
- Add a Label to its Hierarchy, and Save and Exit UI Builder
- Create another UXML Document
- In the Library section, navigate to the "Project" tab
- Expand the "Assets" foldout and drag the previously created UXML Document into the Hierarchy
- Select the TemplateContainer and rename it to anything
- Once renamed, right-click and select "Open Instance in Context"
- Select the Label in the Hierarchy and rename it to anything
- Click Ctrl+Z twice
- Observe the UI Builder and the Console
Actual results: Label disappears from the UI Builder view and "Invalid UXML or USS: System.IndexOutOfRangeException", "NullReferenceException: Object reference not set to an instance of an object" and "IndexOutOfRangeException: Index was outside the bounds of the array." errors are thrown
Expected results: Undo operation is performed with no errors
Reproducible with versions: 6000.0.75f1, 6000.3.16f1, 6000.4.8f1, 6000.5.0b9, 6000.6.0a5
Tested on (OS): Windows 11
Notes:
- Reproduction can be quite inconsistent and it might be needed to repeat 7-10th steps a few times with returning from Context mode and going back