OrchardCore: "Blocked attempt to show a 'beforeunload' confirmation panel" when navigating away from MenuPart editor
Describe the bug
To Reproduce
This is vague and needs more investigation since I see the actual browser log entry only during UI tests (here). Thus I don’t have a solid repro, but the issue does come up reliably if you run that test. So, supposedly:
- Navigate to a MenuPart editor, e.g. the editor of Main Menu when you’ve set up the site with the blog recipe.
- Don’t do anything (?) or perhaps only edit the Title (but not the menu items, don’t change their order, for example).
- Do anything that causes you to navigate away.
- Note a browser console entry similar to this one in Chrome:
3/21/2022 7:49:13 PM UTC | Severe | intervention | https://localhost:9024/Admin/Contents/ContentItems/4nqq58rc9skbf6pdnmhzn3mmx7/Edit?admin=-1181914940 - Blocked attempt to show a 'beforeunload' confirmation panel for a frame that never had a user gesture since its load. https://www.chromestatus.com/feature/5082396709879808
This is because of the window.onbeforeunload code in MenuPart.Edit.cshtml (though it ought to not display a dialog unless the menu items’ order is changed). See the linked https://chromestatus.com/feature/5082396709879808 and https://developer.mozilla.org/en-US/docs/Web/API/BeforeUnloadEvent.
Note that TaxonomyPart.Edit.cshtml has the same issue.
Expected behavior
No console log entry.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 16 (16 by maintainers)
You should see the browser window when you use the default config of the sample project. Otherwise, set
falsehere: https://github.com/Lombiq/UI-Testing-Toolbox/blob/a874a575e177016a56cf846a12371b730e0f0298/Lombiq.Tests.UI.Samples/UITestBase.cs#L56Check out https://github.com/OrchardCMS/OrchardCore/pull/11194 and run the
TestAdminPagesAsMonkeyRecursivelyShouldWorkWithAdminUsertest without theconfiguration.AssertBrowserLogassignment. You should get this error within a few seconds. (If you attach the debugger and break at exceptions, you can also stop the test at that point.)I won’t be able to in the next days, but if you checkout the OSOCE solution, the test linked in the issue will be there. If you change the
[Theory, Chrome]attributes on it to[Theory, Edge]then it should be run in Edge (but we didn’t use Edge, this happened under Chrome).