Skip to content

Input fields lose keyboard focus after cancelling beforeunload dialog in multiple tabs #451

Description

@BhavikGedia

Steps to reproduce the problem

Code snippet: confirmationDialogIssue.html
Issue video: https://drive.google.com/file/d/15R2esW1iJMAyEwXRNA98IoLtIB9_A5Cm/view?usp=drive_link

Reproduction Steps:

  1. Create a page containing a single text input.

  2. Register a beforeunload handler:

    window.addEventListener("beforeunload", function(e) {
    e.preventDefault();
    e.returnValue = "";
    });

  3. Open this page in Edge.

  4. Open another browser tab.

  5. Switch to the second tab.

  6. Click the browser Close (X) button to close the browser window.

  7. Edge activates the first tab and displays the native "Leave site?" confirmation dialog.

  8. Click "Cancel".

  9. Click inside the text input.

  10. Attempt to type.

Expected Result: The input should receive keyboard focus and accept typing after cancelling the native beforeunload dialog.

Actual Result: The input no longer accepts keyboard input.

Minimal Reproduction:

<!doctype html>
<html> <body>
<input type="text" placeholder="Type here">
<script>
  window.addEventListener("beforeunload", function(e) { 
    e.preventDefault();
    e.returnValue = ""; 
  }); 
</script>
</body> </html>

Additional Details:

  • Operating System: Windows 11 Enterprise
  • Also reproduced in: Chrome (Chromium Issue: #537814749)
  • Does NOT reproduce in: Mozilla Firefox
  • The same behavior occurs in:
    1. Plain HTML (no framework)
    2. Angular 18 application

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions