Prevent the loss of an unsaved project issue if the issue tab is navigated away from; save issue as draft #42581
Replies: 15 comments 10 replies
-
|
Hey @matt-y! I find a way to restore my large draft issue as described in this twitter. You may find your draft issue cached inside Developer Tools -> Application -> Session Storage. |
Beta Was this translation helpful? Give feedback.
-
|
At least confirm that the user knows that they are leaving the page and will be losing work, like other web pages do. |
Beta Was this translation helpful? Give feedback.
-
|
I spent more than 1.5 hours and write each my important thaught process and attaching the video i lost the entire my draft. |
Beta Was this translation helpful? Give feedback.
-
|
Is there a technical reason why issue drafts are not a thing..? |
Beta Was this translation helpful? Give feedback.
-
|
Bad design! |
Beta Was this translation helpful? Give feedback.
-
|
A popup to make sure the user does want to quit the page is mandatory, I've just lost 1h of work by accidentally closing the wrong browser window (and it seems the session storage isn't saved when closing the window) |
Beta Was this translation helpful? Give feedback.
-
|
I had the same when I had to restart my computer. The solution would be to use this trick in the frontend: window.onbeforeunload = function() {return "Ticket is not submitted yet. Are you sure you want to close?."}
window.onbeforeunload = null // Safe to close window |
Beta Was this translation helpful? Give feedback.
-
|
As it happened to me for the SECOND time in two weeks, I came up with this little GreaseMonkey (or TamperMonkey/ViolentMonkey) script that simply adds a popup before closing an issue when it has been modified. Note that I've never developed this kind of script so there might be better ways to do that, but here it is if anyone is interested: https://gist.github.com/leleogere/0d021d26bde8ff5fba3006c1d0c309fb EDIT: Replaced the script by a gist link, unfold this to see the initial script.// ==UserScript==
// @name Confirm Before Closing Unsubmitted GitHub Issue
// @namespace None
// @version 1.0
// @description Warn before closing a tab with an unsubmitted GitHub issue
// @match https://github.com/*/*/issues/new
// ==/UserScript==
(function () {
'use strict';
let hasFormBeenModified = false;
// Selectors for input fields on the issue form
const titleSelector = '#issue_title';
const commentSelector = '#issue_body';
// Monitor input fields for changes
const monitorChanges = () => {
const titleField = document.querySelector(titleSelector);
const commentField = document.querySelector(commentSelector);
if (titleField && commentField) {
titleField.addEventListener('input', () => {
hasFormBeenModified = true;
});
commentField.addEventListener('input', () => {
hasFormBeenModified = true;
});
}
};
// Warn user when trying to close the tab
window.addEventListener('beforeunload', (event) => {
if (hasFormBeenModified) {
const message = 'This issue has not been submitted, are you sure you want to leave?';
event.returnValue = message; // Standard for older browsers
return message; // For modern browsers
}
});
// Initialize the script after DOM is fully loaded
window.addEventListener('load', () => {
monitorChanges();
});
})(); |
Beta Was this translation helpful? Give feedback.
-
|
Undo the Tab close: Ctrl-Shift-T if it was closed, or navigate to Go open the Issue again, copy the URL, paste it in each Tab where it might have been opened before, restore closed Tabs/Windows, do the same in them until you see the draft Issue recovered. The same goes for the workaround with Session Storage from above. This is different with Discussions, where text is stored upon tab close into Local Storage, then retrieved when that page is opened again even after PC restart. @leleogere do you have this in a git or would you put it somewhere it can be edited? It needs fixing.
|
Beta Was this translation helpful? Give feedback.
-
|
@paponius I replaced the script with a gist link: https://gist.github.com/leleogere/0d021d26bde8ff5fba3006c1d0c309fb I've modified the EDIT: It is not easy as it seems, and won't work reliably. Have a look at the discussion below the linked gist to get more details. |
Beta Was this translation helpful? Give feedback.
-
|
I have lost an hour-long draft, and just want to complain here. |
Beta Was this translation helpful? Give feedback.
-
|
This is still an issue in 2025 unfortunately. There is no prompt at all when closing the tab/window and no way to restore the issue content. Because it does not happen with repos without issue template, I forgot about it and ended up losing my issue text completely. |
Beta Was this translation helpful? Give feedback.
-
|
While I tried to get an automatic way to prevent closing an unsubmitted issue, it was not as easy as I thought to reliably detect a "new issue" page. As a workaround, and waiting for GitHub to implement a proper solution, you can use a simple bookmarklet to manually "lock" a tab, so that it will ask for confirmation before closing or navigating away. Simply create a new bookmark, and in the URL field input: javascript:(function(){window.onbeforeunload=function(){return 'Are you sure you want to leave this page?';};alert('Tab locked.');})();Now, when you start to write a new issue (or any website you do not want to close by mistake), do not forget to first click your new bookmark, so that the browser will warn you before closing that tab. It might not be as convenient as an automatic trigger, but that's better than nothing! Important note: It might not work with all browsers. Also, in some browser such as Firefox, you will need to interact once with the page after clicking the bookmark so that the Extensions like Page Lock might be another alternative. |
Beta Was this translation helpful? Give feedback.
-
|
Lost a lot of work. Still no auto-save draft feature. All websites have this. It's 2025 :( |
Beta Was this translation helpful? Give feedback.
-
|
I recently had Firefox crash on me (don't use snap, use apt), and I went seeking in Firefox state cache files and it was a miserable time wasting endeavour. I did not manage to reconstruct the input state. Truly a necessity. I now meticulously move over my drafts half way in when it clicks that I have invested quite some time in a draft that could become dust in the wind in a blink of an eye. |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
Select Topic Area
Product Feedback
Body
I just lost an enormous issue ticket that I was writing by accidentally changing tabs in a github project. This is frustrating, to put it lightly.
I'd like to be able to save an issue as a draft, and have it not show up in the project's active issue list until I've completed it. This allows me to not have to complete a large ticket in a single sitting, and allows me to add details over time. It is very difficult to write a comprehensive issue without being able to save it.
Alternatively, can the github UI somehow warn me that I am navigating away from unsaved work? It should not be possible to just have a multiple paragraph long issue ticket complete with screenshots and etc just vanish when you accidentally click something that takes you away form the form.
Beta Was this translation helpful? Give feedback.
All reactions