When closing a tab or navigating away from the page we should warn the user if they have unsaved changes. This is done with the onbeforeunload handler.
@Esanders: I am getting this warning message from the browser when I am closing the tab without posting a reply that I typed. Also, while navigating away to the other tabs except "Edit Source" tab.
When I type a reply and click on "Edit Source" tab, it navigates away from the page without giving any warning.
Is it the correct behavior?
My theory is that @Ryasmeen has NWE enabled, and so "edit source" isn't technically a navigation event (because it's just replacing the contents of the current page). We need to special case detecting and canceling this somehow.
@Ryasmeen If you don't have NWE enabled, let me know, because that'd demolish my theory. 😁
Good spot, @DLynch.
David, can you describe this in a bit more detail? Does "special case detecting and cancelling" refer to writing a patch to make it so the browser displays a warning message  before contributors who a) have NWE enabled and b) have started writing a reply click "Edit source"?
- Browser warning message: "Leave site? / Changes you made may not be saved."