pkp/pkp-lib — comment on commit 50620d60a4c9e9563e9dd85f79150640115e1f22
File: js/controllers/form/FormHandler.js line 60
By beghelli:

Hi Jason,

I like the idea of using the notifications with this feature, but we have to think how to do this right. We can't use notifyUser event to let forms communicate that they have unsaved data because this event will instantly fetch and show a notification. I think that what I described on my last message will still need to be done, because it's a structure for letting form widgets communicate that they have unsaved data. With this, every widget that needs to implement a different logic for this feature will have a chance. What you are proposing now, as I understand, is more how we will present the message to user, and it makes sense to me to use our notifications system.

Another point in your message: we can't rely on redirectToUrl method only, because not all site redirections use this method. And user can type an url on browser too, so, we need the beforeunload event, really.

Just to confirm, this feature you are implementing needs to receive user input right? Because I think we have to give users the chance to leave the page even if there is unsaved data there. Then, my concern is how we deal the user input, if we are not going to use the default javascript event.

Maybe we can trigger a notify user event when beforeunload is triggered (and when we have unsaved data, of course), and make the beforeunload handler return the user input that the notification received. I think this can work, but, as I said, I need to code a little to check.

Another issue is that, until now, we don't have any case where a notification pop up and don't leave until user gives a response to it. But maybe it's just a matter of configuring the pnotify for this case.