Reproduction steps:
1. Create a new 3D project
2. In the Hierarchy window, right-click anywhere
3. In the menu context, go through the submenus
Expected result: Menus and submenus appear normally, without any glitches such as disappearing or errors
Actual result: Menus and submenus glitch out and disappear, and errors start appearing in the Console
Reproducible with: 2023.2.0a15, 2023.2.0b10, 2023.3.0a6
Not reproducible with: 2021.3.30f1, 2022.3.10f1, 2023.2.0a14
Reproducible on: Ubuntu 23.04
Not reproducible on: Windows 10 Pro 22H2
Note: The issue does not reproduce every time, but there is a noticeable sluggishness on the sub-menus, which may indicate that the issue will reproduce eventually