Skip to content

Multiple windows cause the "close" event to be triggered multiple times #8252

Open
@ssnangua

Description

@ssnangua

index.html

<script>
  const win = nw.Window.get();
  let close = false;
  win.on("close", () => {
    alert(close);
    if (close) win.close(true);
    else close = true;
  });
</script>

main.js

// When there is only one window, it works fine:
//      first time: alert `false`
//     second time: alert `true` -> close the window
nw.Window.open("index.html");

// When there are multiple windows, closing any window will trigger the "close" event twice, and then automatically close the window:
//      first time: alert `false` -> alert `true` -> close the window
nw.Window.open("index.html");
nw.Window.open("index.html");

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions