Mail app shows a confirmation popup before leaving - beforeunload listener not removed when closing composer
Steps to reproduce
1.Open Nextcloud Mail 2.Start composing a new message 3.Close the composer without sending - draft is saved automatically 4.Navigate to another Nextcloud app 5.Confirmation popup is displayed
Expected behavior
The browser should not prompt for confirmation when navigating away after the composer is closed and draft message has been saved
Actual behavior
Browser shows a popup asking for confirmation before leaving, even after the composer is closed.
Reproducible on many instances
Mail app version
5.9 - behavior started at around 5.7
Nextcloud version
33.0.5
Mailserver or service
Any
Operating system
Any
PHP engine version
Any
Nextcloud memory caching
No response
Web server
None
Database
None
Additional info
Using beforeunload event listener monitor in the browser console, you can see that the listener registered in NewMessageModal.vue (created() hook) is never removed after the composer is closed.
Patch used in browser console to identify :
const _orig = window.addEventListener.bind(window);
const _origRemove = window.removeEventListener.bind(window);
window.addEventListener = function(type, fn, opts) {
if (type === 'beforeunload') {
console.trace('beforeunload ADDED', fn);
}
return _orig(type, fn, opts);
};
window.removeEventListener = function(type, fn, opts) {
if (type === 'beforeunload') {
console.trace('beforeunload REMOVED', fn);
}
return _origRemove(type, fn, opts);
};
The removeEventListener call in beforeUnmount() is never reached, suggesting the component is not being fully unmounted when the composer is dismissed.
Hi, i can reproduce this issue, thank you for taking the time to report it.
Hello, I also reproduced this issue, but it can also be triggered without composing, for example:
- Open nextcloud,
- click on email to open it in read pane
- click on any folder, then back on the email again
and I think it also manifests itself when trying to move an email to a folder by drag and drop - all folders are greyed out.
This started happening around 5.7, not earlier. HTH