-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace jquery.are-you-sure
with @github/session-resume
#26743
Conversation
Actually
That's why "AJAX" is before the "LocalStorage Draft" in "that" summary issue. |
I don't understand these points entirely but I think they are not blockers. The API used here is very flexible, I imagine you can extend it with custom AJAX-related functionality. |
|
What is "clean the draft"? |
And one more problem: some UI heavily depends on the "input" event. Even if the "input" element content is restored, the UI would be in a inconsistent state (eg: auto showing something when the input has some contents). I do not think "session-resume" is the right approach. |
We can trigger a manual
I think it is absolutely the right approach and a huge improvement over previous annoying modal popup. GitHub has been using it for years. It ought to work for us as well. |
It needs a complete framework design with documents and demos. |
I agree with silvermind here, point 2 as mentioned by wxiaoguang ajax is successful we can call the form to reset. |
I don't want to go overboard with this. Just a simple replacement. If there are issues later, we can solve them individually. Generally, improvements related to network interruptions should like be upstreamed into the module. |
Without a clear design and explicitly defined behaviors, it might go on the wrong way, just like some old designs ........ |
This comment was marked as off-topic.
This comment was marked as off-topic.
The module already dispatches a |
One more problem, I do not think GitHub's "session-resume" works for various cases. I have experienced content losing many times on GitHub. Actually, GitHub session-resume declares:
I guess if people close the tab, then the content won't be able to recover. |
|
Yup, so, there are really a lot of questions. That's why I believe that it needs a design document and demos first, it needs to have explicitly defined stable behaviors. |
I'm not going to write documents for this, sorry. For me, this is good enough. All I personally need is persistence across F5 and I am happy how it works on GitHub. A more elborate system that persists into |
@wxiaoguang I hope you can accept the current simple solution. It works for GitHub, so it likely will work for us. I'm definitely not going to write a overengineered implementation for something I don't personally need. |
Do you have real cases to say so? I have fixed so many unfixable bugs, a lot of them are caused by bad designs. Even for the markdown editor, the refactoring got stale for that long time, it's also partially caused by the messy code / bad design in history. I have spent so much time on making the code base clear and stable. At least, isn't it nature to make every developer understand the newly introduced behaviors clearly? |
I will try to summarize the The backgroundAvoid losing user input, to improve user experience
|
I think we can try switchting this to use localStorage. That will persist data pretty much indefinitely at the cost of potentially accumulating some garbage over time. It may also be possible to add a timestamp to those entries to perform a "garbage collection". |
I guess using Another candidate for this mechanism may be the install page. |
@wxiaoguang do you by chance know which mechanism currently restores the issue/pr textarea? Is that a browser-native mechanism or something from our JS? |
Not @wxiaoguang, but I think it is the local storage/browser cache |
As I understand it, browser should clear a textarea on page reload. Enter something and hit https://jsfiddle.net/silverwind/48oqL6y2/ The only reason a browser might keep it is when the page is restored from bfcache, but bfcache does not apply on a reload and in fact our |
Maybe related to: ? |
Hmm could be, but I guess this behaviour may vary between browsers. Generally bfcache seems to be something that is not standardized at all, so it will be good to have our own restoration in any case. |
Extract from #25940 and because #26743 does seem to need more work. This will be required if we are to run our JS in [strict mode](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode). Previously, the two variables `$fields` and `$dirtyForms` polluted `window`: <img width="1145" alt="image" src="https://github.com/go-gitea/gitea/assets/115237/e0270a0e-b881-4ed7-9cc4-e9ab25c0a2bc">
Not going to continue here, but I still feel the approach is right and it should be attempted again to migrate away from |
With @github/js-session-resumable, content in
<input>
and<textarea>
is automatically saved and restored on page reload, eliminating the need to display a popup. This is using a allowlist-based approach where each restorable element needs to have ajs-session-resumable
class, which is much better than the previousignore-dirty
madness.Currently I've only added this to the markup editor and the new issue/pr form.
@wxiaoguang there seems to be an existing mechanism somewhere that restores the markup editor content even without this resumation enabled. Can you help me find it so I can remove it?