Shake to Undo deletes Edits without warning

Shake to undo is fine if all I’ve done is press easy/hard/whatever.

Shake to undo is a bit aggressive if I’ve actually edited a card - it would be nicer if it gave a warning before proceeding.

The background to this is that sometimes when I let the iPhone go to sleep with Anki open, it does/has done an undo when it comes back, which has sometimes meant I’ve lost edits.

I suspect this is because of shake to undo, though it’s hard to know how to test this - if I give it a shake I can reproduce the behaviour, but that’s very deliberate.

I don’t have another way to reproduce it on demand. This isn’t a sync issue.

I’m going to try turning off shake to undo, which may or may not fix my main problem, but even if it does, I still think that shake to undo shouldn’t undo edits, not without a confirmation anyway.

The standard iOS app behavior is that when you shake to undo, a confirmation alert appears asking the user if they want to Undo or if they instead want to Cancel the operation. The AnkiMobile app might want to consider changing its behavior to add this confirmation alert.

From Apple Developer Guidelines:

Help people predict the results of undo and redo as much as possible. On iPhone, for example, you can describe the result in the alert that displays when people shake the device, giving them the option of performing the undo or canceling it.

If you accidentally undo something, you can usually “redo” it. Have you tried that? Redo is available in the ⚙️ Study Tools menu and in ⚙️ Preferences – and it should say what it is redo-ing.

I haven’t been able to reproduce note edits that are actually lost. But as you pointed out, changing the shake action to something else (or “Off”) will prevent this from happening.

As far as I can tell, AnkiMobile has 2 behaviors –

  • If the thing can be easily “redone,” the shake-undo happens automatically with just a brief pop-up, and Redo is available in the menus.
  • If the thing cannot be easily “redone” (like typing something in a note that is still open for editing), the shake-undo gives a confirmation alert instead.

Interesting. I didn’t realise that was an option.
I’ll turn shake to undo back on and see what happens.
Part of the problem is that, apart from not knowing about the Redo option, I don’t always realise that it’s happened.

If you have a lot of accidental shakes in your daily use of your device – you should just turn off shake-to-undo. It’s more trouble than it’s worth.

I don’t normally have any accidental shakes.
I’m not 100% sure that accidental shakes are the problem here.
It’s just the best theory I have at the moment.
All I know for sure is that something sometimes causes Anki to do an undo, if I let it go to sleep and then wake it up again.
Not often, just sometimes, when I open Anki, I’ve had changes vanish.
And sometimes, it looks like the below.

So I am confident that something is triggering an undo.

I’ve been able to reproduce the problem often enough that I’m sure it’s real.
But I haven’t been able to find a reproducible use case.

Shake is my best suspect, but I’m far from sure of anything much.

If the Undo queue is empty, that means something wasn’t recently done. And if what was recently done was an Undo – then Redo would be available. So let’s set aside the shake-action for a moment –

This helps expand the field of possibilities.

  1. What kinds of things have you had vanish? Is it always edits to a field in a note? Or are there other things – settings changes, review history, etc.?
  2. For edits – are you confident that you’ve closed the edit-note window with “Save” to commit the edit to the database? That’s something you don’t have to do on desktop, but it’s necessary in both of the mobile apps.
  3. When you come back to the app later, is the app still open? Asked another way (or possibly a different question entirely) – are you still in the same part (screen, menu, etc.) of the app? Or are you returned to the main Decks list?

It’s fine if you don’t have answers for these now, but these can be things you watch out for in the future.

  1. What kinds of things have you had vanish? Is it always edits to a field in a note? Or are there other things – settings changes, review history, etc.?

The ones I care about are edits to a note. I’ve had progress lost, but that’s no big deal. Never setting changes, but I don’t make those often and when I do it’s always going to be at the start/during a session. So I wouldn’t expect to have lost setting changes.
2. For edits – are you confident that you’ve closed the edit-note window with “Save” to commit the edit to the database? That’s something you don’t have to do on desktop, but it’s necessary in both of the mobile apps.

Yes. Certain.

If I do shake it during an edit, it prompts to ask if I want to “Undo Typing” with options “Cancel” and “Undo”.

But if I Save, then shake, it goes straight to “Answer card undone”. As discussed earlier, Redo works at this point, but only if the user knows that they can Redo, and realises that they should Redo.

  1. When you come back to the app later, is the app still open? … are you still in the same part (screen, menu, etc.) of the app?

Yes, I’ve only seen this happen when I leave the app open on the next card. It can go undo one card, or even a few cards.

I assume it happens if I put the phone down/away with too much motion. It’s quite easy to repeat if I try.

I do sometimes see the “Error UndoEmpty” message when I open the app.

I’ve never seen the “Answer card undone” message, which makes me think it’s when I put it down/away, rather then when I pick it up/unlock it.

Or are you returned to the main Decks list?

No. Only when I leave it on a card and it always stays in the same deck, just not on the same card.

It seems to me that this is the most telling part of what you wrote. That means that the edit you made is not recorded in the undo-queue – or at least, that it’s not the most recent thing in the undo-queue. That makes it seem like the edit wasn’t saved to the database at all, so losing it might not be related to shake-undo.

For now, stick with disabling shake-undo. And if you’re still seeing instances where you save a change and it isn’t actually saved, there could be more for us to talk about.

If there’s something to undo, then it gets undone. And I assume there’s a message, if only fleetingly.
When there’s nothing to undo, then and only then is there the error message.