question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Window doesn't close with `close` event handler and window.close()

See original GitHub issue

NWJS Version : 0.58.0 Operating System : Windows 10

Expected behavior

When a window uses window.close(), handling of the close event should behave the same as if nw.Window.get().close() was called or the user manually closed the window.

Actual behavior

If window.close() is used to close a window, an event handler cannot be attached to the close event. If an event is attached, the window does not actually close when win.close(true) is called.

How to reproduce

  1. Open NW.js SDK and open the DevTools console.
  2. Execute:
nw.Window.get().on('close', function() {
  this.close(true);
});
  1. Execute:
window.close();
  1. Note that the window does not close. However, the user can no longer interact with the window.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
TheJaredWilcurtcommented, Nov 29, 2021

nw7808.zip

Version win.close() nw.App.quit() window.close() process.exit(0) process.exit(1)
0.42.0 ✔️ ✔️ ✔️ ✔️ ✔️
0.42.1 ✔️ ✔️ ✔️ ✔️ ✔️
0.42.2 ✔️ ✔️ ✔️ ✔️ ✔️
0.42.3 ✔️ ✔️ ✔️ ✔️ ✔️
0.42.4 ✔️ ✔️ ✔️
0.45.0 ✔️ ✔️ ✔️
0.46.0 ✔️ ✔️ ✔️
0.46.1 ✔️ ✔️ ✔️
0.46.2 ✔️ ✔️ ✔️
0.46.3 ✔️ ✔️
0.58.0 ✔️ ✔️

@rogerwang Updated table with tested versions and relevant diffs

0reactions
rogerwangcommented, Nov 23, 2021

Thanks for the sample and testing. but the bug is in 0.50.0 as well

Read more comments on GitHub >

github_iconTop Results From Across the Web

window.close and self.close do not close the window in ...
The issue is that when I invoke window. close() or self. close() it doesn't close the window. Now there seems to be a...
Read more >
Window.close() - Web APIs - MDN Web Docs - Mozilla
The Window.close() method closes the current window, or the window on which it was called. This method can only be called on windows...
Read more >
Window.Closing Event (System.Windows)
The Closing event is raised when Close is called, if a window's Close button is clicked, or if the user presses ALT+F4. If...
Read more >
Closing a Window with JavaScript
Now click the “Close me” in the child. It closes. Viola! That window closed itself. Observations below. Conclusion: Since we opened the child...
Read more >
wx.CloseEvent — wxPython Phoenix 4.2.0 documentation
This event class contains information about window and session close events. The handler function for EVT_CLOSE is called when the user has tried...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found