go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
45.02k stars 5.49k forks source link

Option for "Leave site?" warning #20347

Closed Ryan-pelo closed 1 year ago

Ryan-pelo commented 2 years ago

Feature Description

A few times I have been typing a long comment or post and accidently clicked a link or refreshed the page. Then all my work is gone and non-recoverable. I would appreciate having a "Leave Site?" dialogue box if I have unsaved content in a text box.

Screenshots

Screenshot 2022-07-12 140337

wxiaoguang commented 2 years ago

Related:

silverwind commented 2 years ago

There is already a warning via jquery.are-you-sure, but I'm not sure whether it will catch all changes, I think it only looks at stuff inside <form>.

Also, we really need to eliminate all cases of window.reload in JS. Might require new APIs to be added thought.

wxiaoguang commented 1 year ago

Some details & background:

Before SimpleMDE/EasyMDE, there is a global $.areYourSure confirm (using onbeforeunload) for comment textarea. Everything was just "fine".

However, after introducing SimpleMDE/EasyMDE, $.areYourSure doesn't work well with SimpleMDE/EasyMDE editor, so the situation became what you see now.

silverwind commented 1 year ago

Another reason to add to the list of like 30+ other issues on why we should remove EasyMDE and replace it with a textarea.

wxiaoguang commented 1 year ago

I could also agree to remove the EasyMDE if there is no strong objection from user side.

silverwind commented 1 year ago

Yes I think the majority of users is for it, see https://github.com/go-gitea/gitea/issues/10729.

wxiaoguang commented 1 year ago

Then let's do it?

silverwind commented 1 year ago

Yes, I think the approach in https://github.com/go-gitea/gitea/pull/15394 with the github toolbar is still ideal. If you have the capacity to do it, please go ahead, I'm happy to review.

lunny commented 1 year ago

Should be fixed by #23895

silverwind commented 1 year ago

Works now with https://github.com/go-gitea/gitea/pull/23876

Screenshot 2023-04-03 at 22 34 48