frontend
frontend copied to clipboard
Browser's "back" button + cancelling unsaved changes prompt resets Editor code
- 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.
- However, if you click "go back" button in the browser, after responding the prompt, your unsaved changes get discarded.
- 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
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?
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.
Ok, I've narrowed down the issue.
- 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 👍
When navigating away from a page, e.g. from back button/backspace, then cancel will remove unsaved code.
Press the cancel button
Removing minor tag because swiping across page in mac causes the page to navigate backward.