Regex101 icon indicating copy to clipboard operation
Regex101 copied to clipboard

"This page is asking you to confirm that you want to leave — information you’ve entered may not be saved."

Open lotas opened this issue 1 year ago • 5 comments

Bug Description

Currently if you have nothing entered in Regular expression and Test string fields, and try to close the page, it still shows the warning

image

Reproduction steps

  1. go to https://regex101.com/
  2. enter any character in any field
  3. remove it
  4. try to close the page

Expected Outcome

Warning is not shown.

Browser

Firefox 128

OS

MacOS

On a side note, the requirement to click through an extra popup confirmation when closing the tab or navigating away is quite disturbing, imho. Wouldn't it be more user-friendly to use session storage or local storage to automatically save the currently entered text? This way, if a user accidentally closes the tab, they can reopen it and return to their last entered state without the disruption of a confirmation popup.

Thank you for considering this improvement.

lotas avatar Jun 10 '24 14:06 lotas

Hello! This is a good point that it should not bug when you've cleared all input from both fields, but there's also the matter of undo. What if the question triggers your memory and you realize you had some text a couple iterations back and you want it back?

As far as the suggestion to save the input to localStorage, that may be feasible, but there are some considerations:

  • each tab needs to be given a unique session id to track it among the other tabs the user may have open
  • all browsers should consistently restore localStorage as well when restoring a tab
  • there's a way to detect a tab was reopened for all browsers (I know there's some specific ways for Chrome-based and Firefox but not sure about Safari for example) to prompt the user or simply restore the content
  • the next logical step is for a user to request access to all edit history too, which means more code for CM integration to save and restore its history
  • the added burden of maintaining this feature's code has to be worth it

working-name avatar Jun 10 '24 15:06 working-name

Thanks @working-name I only mentioned using storage as an alternative to a not worrying about not loosing the progress. I'm pretty sure there might be different ways of achieving this. Like keeping a "recent regexps" history could be sufficient.

As an example, I've just closed this tab as I was typing in a comment, and github didn't block it with a modal window asking me to confirm it. Instead, on re-open, my message was still here.

Plus I think that this should be still labeled as bug, because the inputs are empty when I'm closing the window. Thanks

lotas avatar Jun 10 '24 17:06 lotas

Gotcha, thank you.

The reason I didn't leave it as a bug is because this doesn't happen unless you make edits. That qualifies as "information you've entered may not be saved". If you do not actually enter any information in the first place the prompt does not appear. At least not in any browsers I've tested, including Firefox. Do you find that prompt appears when you input nothing at all as well? That would be a bug, indeed.

working-name avatar Jun 10 '24 18:06 working-name

I do make edits :) but then remove them, either by hitting backspace or doing Undo action. In any case the input is blank. My point is that if the inputs are blank there is no need for extra confirmation dialog window. /shrug

lotas avatar Jun 10 '24 18:06 lotas

I see where you're coming from. What happens is that as soon as something is changed in the editor, a flag is set, and this popup will be shown if the data is not saved.

I have considered saving things to storage automatically multiple times, but I haven't ironed out how to handle the UX of having multiple tabs at the same time. Which tabs data should I save? Should they overwrite each other? Etc.

firasdib avatar Aug 11 '24 08:08 firasdib

I don't think this logic is worth complicating, so I will leave it as is for now.

firasdib avatar Jan 07 '25 13:01 firasdib

I don't think this logic is very complicated and don't agree that empty input should trigger alert to block navigation. Just my opinion. Thanks

lotas avatar Jan 07 '25 13:01 lotas