mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-09-02 01:20:23 +08:00
The draw.io iframe registers a window.onbeforeunload handler that returns a non-empty string whenever its internal editor.modified flag is true. After the user edits text in a shape, that flag is set and never cleared. Per Electron BrowserWindow docs, returning a non-void value from any beforeunload handler in the page tree silently cancels the window close without showing a dialog. This is what caused the X button (and Cmd+Q) to do nothing for users who had typed in a shape. Calling event.preventDefault() in will-prevent-unload tells Electron to ignore the iframe's beforeunload return value and proceed with the close. The host app already persists diagrams via autosave + visibilitychange, so the prompt was unnecessary. Verified by reproducing the bug, applying the fix, and re-testing.