Skip to content
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

Allow web IDE to save and/or show warning before navigating away from page (eg. refresh) #78

Closed
0xdevalias opened this issue May 16, 2024 · 5 comments · Fixed by #79
Closed
Labels
enhancement New feature or request playground

Comments

@0xdevalias
Copy link

0xdevalias commented May 16, 2024

It would be cool if the web IDE allowed us to save to browser storage, or at the very least showed a popup/confirmation if we try to navigate away from /refresh the page while working on something.

I'm not sure why my muscle memory was doing it, but I kept hitting cmd+R to try and rename variables yesterday, and lost my in-progress work like 5 times before I managed to force myself to stop pressing it.

Potentially relevant:

@j4k0xb
Copy link
Owner

j4k0xb commented May 17, 2024

Done, it now saves and shows a prompt for 5s when loading the site
Can you try it? https://deploy-preview-79--webcrack.netlify.app/
image

@0xdevalias
Copy link
Author

0xdevalias commented May 18, 2024

Done, it now saves and shows a prompt for 5s when loading the site
Can you try it?

@j4k0xb That is pretty cool!

A few notes:

  • Being down in the bottom right corner, I didn't notice it immediately.
  • There was no UI indication that it would only be visible for 5 seconds. Maybe showing a countdown on it would help with that?
  • Even better still, at least for me, I would prefer no countdown at all, and it to persist until I closed it, as that seems a fairly minor inconvenience (maybe it could be configurable if it would be annoying to others)
  • I noticed that technically, even if the dialog goes away and I didn't click either, if I then reload the page again I can get it back (unsure if that would have the old state, or the new state 'empty' state.
  • While this offers a nice 'recovery option', my original thinking (and still likely better UX for me) would probably be to warn with a 'you have unsaved changes, are you sure you want to leave' sort of confirmation. If this would be annoying for people, maybe making it configurable would work? If you did implement this, I would still keep the 'recover dialog' as well, as that is a super nice UX.

Also did a little code review with some thoughts/notes added there:

@j4k0xb
Copy link
Owner

j4k0xb commented May 18, 2024

While this offers a nice 'recovery option', my original thinking (and still likely better UX for me) would probably be to warn with a 'you have unsaved changes, are you sure you want to leave' sort of confirmation. If this would be annoying for people, maybe making it configurable would work

True, gonna add that
Adding a config might not even be necessary because browsers show that option
Nvm still needed, it resets after a reload
image

I'll probably remove the restore alert (annoying when it appears on pretty much every site load) and think of some other place in the sidebar that can be used at any time, which should also result in better UX

@0xdevalias
Copy link
Author

True, gonna add that

@j4k0xb Awesome!

I'll probably remove the restore alert and think of some other place in the sidebar that can be used at any time

@j4k0xb nods sounds good. I agree that that feels like a better UX as well.

Maybe instead of just saving the files 'as is', there could be some notion of like a 'session' or similar that they get saved into? Not sure if this is overengineering it, but was sort of thinking in terms of thinking a bit like Chrome tab history/restore/similar.

Like, a completely arbitrary off the top of my head example could be that when the web app loads, it creates a UUID for that current session, and then any files that are written to storage are keyed with that UUID (and probably a 'last updated' timestamp; perhaps for the session overall, and the file).

Then in the 'restore UI', it could show the last X sessions (sorted by timestamp); or something to that effect.

(With this, was mostly thinking that since the 'restore state' is going to persist longer than 5sec now; it might make sense to try and scope/group the 'files' a bit more 'logically'; so that a new session doesn't inadvertently wipe out the old one)

@0xdevalias
Copy link
Author

0xdevalias commented Jun 8, 2024

Just had a chance to quickly test this now that #79 has landed.

Trying to refresh the page (with unsaved content):

image

Trying to navigate away from the page (with unsaved content):

image

If I do reload/navigate away, when I come back, I can attempt to restore from the 'File' -> 'Open Recent' menu:

image

image

But when I clicked on it, it didn't seem to actually restore the item at all.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request playground
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants