Reproduction steps:
1. Open the attached “BugRepro” project
2. Open the TestWindow (Test > Test)
3. In the TestWindow, press the button
4. Observe that the TestWindow is marked as having unsaved changes
5. Press ESC key to close the window
Expected result: “TestWindow - Unsaved Changes Detected” pop-up shows up
Actual result: The window instantly closes, discarding all the unsaved changes
Reproducible with: 2021.3.38f1, 2022.3.28f1
Not reproducible with: 6000.0.0f1
Reproducible on: Windows 11
Not reproducible on: No other environments tested
Note: If you close the window by pressing the exit button (the red x), the pop-up will show up