mikitex70 / redmine_drawio

Macro plugin to embed draw.io diagrams into Redmine wiki pages
MIT License
121 stars 51 forks source link

Display a warning when reloading or closing an editor page #101

Closed xanadiu closed 2 years ago

xanadiu commented 2 years ago

I wonder if it is possible to prevent the user from accidentally reloading or closing the diagram editor when there are unsaved changes. I know that some browsers ask for confirmation when reloading or closing a page with a form that contains user-entered data. Maybe there is a hook to use this while editing. Or would that be a request for the diagram editor and out of scope for this plugin?

mikitex70 commented 2 years ago

Hi @xanadiu, I've done some test and when clicking in the Exit button of the diagram editor a dialog will popup asking confirmation to discard changes. I've also tried a whole reload of the page (Redmine URL, but the diagram editor is shown) and the the dialog pops up correctly. My tests were done with Firefox. Have you some use case where the dialog does not appear?

xanadiu commented 2 years ago

Hi @mikitex70, sorry for being lazy in not specifying the browser information...

I am working on a Mac (macOS 11.6) and discovered these behaviours (after altering and not explicitly saving the diagram):

Web browser Reload the window Close the window Click on Exit
Safari 15.0 No warning
Diagram editor disappears
Redmine content is shown
Changes are lost
No warning
Window is closed
Changes are lost
Alert (website specific) "All changes will be lost!" with Discard Changes and Cancel options √
Firefox 92.0.1 Alert (browser specific) informs user about unsaved changes √ Alert (browser specific) informs user about unsaved changes √ Alert (website specific) √
Chrome 92.0.4515 Alert (browser specific) informs user about unsaved changes √ Alert (browser specific) informs user about unsaved changes √ Alert (website specific) √

So the problem seems to correlate with Safari...

mikitex70 commented 2 years ago

The check for unsaved diagram is done fully in the diagram editor. Maybe you can try to open an issue on drawio. Before that, do a simple check: go to https://app.diagrams.net/, draw a simple diagram and check with Safari and another browser if it asks for unsaved data.

mikitex70 commented 2 years ago

No more feedback, closing this issue.