frontend icon indicating copy to clipboard operation
frontend copied to clipboard

Browser's "back" button + cancelling unsaved changes prompt resets Editor code

Open le0tan opened this issue 6 years ago • 5 comments

  1. If you try to exit the editor by closing the tab or clicking links elsewhere (instead of closing the browser), SA would prompt that you have unsaved changes and keep your unsaved changes.
  2. However, if you click "go back" button in the browser, after responding the prompt, your unsaved changes get discarded.
  3. What makes things even worse is in mission/quests with multiple sub-problems, after responding the prompt invoked by "go back" once, if you make changes to current problem and click "next" or "previous" to another problem, SA would not prompt that you have not saved your changes, even if you clicked save in the other problem, the changes made to the previous problem get somewhat discarded and not saved.

I made a video to demo this: https://www.youtube.com/watch?v=3GD02NZV47M&feature=youtu.be

le0tan avatar Sep 11 '18 12:09 le0tan

I notice that your video is on an assessment that has already been graded. It is expected that you are unable to make changes to your solution by design, as submitted assessments should not be modified.

The website is a SPA, so you're not recommended to use the browser's "back" button. This causes an effective refresh of the page, relying on your browser's caching and the URL to generate a proper display. Is there any other issue regarding this that you face?

remo5000 avatar Sep 13 '18 07:09 remo5000

I notice that your video is on an assessment that has already been graded. It is expected that you are unable to make changes to your solution by design, as submitted assessments should not be modified.

The website is a SPA, so you're not recommended to use the browser's "back" button. This causes an effective refresh of the page, relying on your browser's caching and the URL to generate a proper display. Is there any other issue regarding this that you face?

The same issue applies to ongoing assessments. It seems that you use hasUnsavedChanges to indicate whether show up prompt or not. The problem possibly lie in not correctly refreshing the variable after "back" operation (i.e. even if there are unsaved changes, the variable remains false) And I'll remember not to use "back" button again, thanks.

le0tan avatar Sep 13 '18 09:09 le0tan

Ok, I've narrowed down the issue.

remo5000 avatar Sep 13 '18 11:09 remo5000

image

  • Unsaved changes are tracked correctly
  • When user click's on "Cancel" in the prompt that informs them of unsaved work, location is still changed, causing a re-fetch of the assessment and overriding the editorValue.

I don't think this is good behaviour so I'm going to be keeping this issue open, but note that the fix will probably be nontrivial i.e won't be fixed during the semester.

Thanks for the catch @le0tan 👍

remo5000 avatar Sep 13 '18 11:09 remo5000

When navigating away from a page, e.g. from back button/backspace, then cancel will remove unsaved code.

image

image Press the cancel button

image

Removing minor tag because swiping across page in mac causes the page to navigate backward.

blackening avatar Sep 05 '19 11:09 blackening