bug: page navigates away with unsaved changes in a text box

While typing a long function in a cell, I somehow got my copy of Firefox here to interpret the backspace key as page navigation before my typing had been committed. The browser navigated back in history, leaving the page. When I went forward again to return to my notebook, my typing was lost.

This reminded me that I need to disable the moronic default backspace behavior in my Firefox here, but there is also an Observable bug here (which I have run into a couple of other times for other reasons, but can’t really remember the details) causing data loss.

If there is something typed in a cell but the cell has not yet been run / saved, the notebook page should put up a modal prompt before letting the browser navigate away. This won’t show up too often (because most of the time the content of all of the cells is committed) so it shouldn’t ever bother anyone. But could save someone from disaster if they for whatever reason do a ton of typing without committing partial results along the way.

4 Likes

Same here. But I usually refresh my browser because of some mistakes that is impossible to be cleaned up. Keeping in mind to hit Shift+Enter after each change I made, I rarely lose my work by accident. I see this issue a feature more than a bug: at least it is a way to quickly discard the change of the current cell (should be implemented as a separate button, though).

1 Like

Ah, that’s an interesting one.

The escape key currently closes the current cell and commits the changes, but it might be nice to have some shortcut for “discard the current typing”.

2 Likes

One possible alternative / addition would be to have an “airplane mode” that prevented the page from being reloaded or navigated away from without confirmation under any circumstances.

Working on a plane (or other context with unavailable, inconsistent, slow, … internet) and accidentally reloading the page and subsequently being unable to continue working is quite frustrating. Thankfully changes are saved within the browser so past work doesn’t get lost, but saving the work time would be nice. (I think someone mentioned this problem in another topic recently, but I can’t find it in a quick search.)

1 Like

I made a github issue for this:

1 Like