Undo erase while snackbar is showing
Added by @bbinto
Why/User Benefit
- Provide a way for user to revert / undo if they hit accidentally on Erase
What
- Include an "Undo" action after Erase button was hit
Acceptance Criteria (how do I know when I’m done?)
- Undo action can be performed and indeed brings you back to previously visited website
- Probe added to track when user hits undo action
Theme: General Improvement
User Story
As a user I want to revert / undo if I hit accidentally on Erase
Background
It just happened that I accidentally erase my browsing session. With no history this can be annoying because I need to get back to the app I came from and click the link again.
We are showing a snackbar once the user erases a browsing session. On Android those snackbars often contain an "undo" action. It would be nice if I could get back to the last URL as long as the snackbar is showing.
Tasks
- [ ] Define scope: Do we just want to reload the last website? Or do we want to restore the last state (history, forms, scroll state)?
- [ ] Add "undo" action to snackbar and implement undo based on scope.
- [ ] UX / animation
- [ ] Add telemetry probe
In theory it's super easy: Keep the fragment around and if the user pressed undo then re-attach it. However I am running into issues with the animations not working correctly and Android re-creating the views without restoring the state.
With the new back button behavior this might be less a concern: Instead of always erasing when going back we now go back to the previous app and the session will not be erased (but we show a notification!)
@brampitoyo -- can you provide some first UX ideas around this?
Animation-wise, it’s easy: when you undo the Erase action, we will also “undo” (reverse) the delete animation.
Our current Erase animation choreography looks like this:
- Erase button disappears
- Last opened webpage becomes more transparent, then slides down
- Firefox Focus logo and keyboard slides up
- Toast slides up
What would it look like if we “undo” (reverse) it?
- Toast slides down
- Firefox Focus logo and keyboard slides down
- Last opened webpage slides up, then becomes more opaque
- While the Erase button slides up (it doesn’t simply appear – @ekager had designed this effect for a separate issue)

Have a look at this slo-mo video for a breakdown of what elements move at what time.
If there are multiple tabs open, the Tab List button can slide up just like to the Erase button.
In terms of UX, we should opt for the most restorative action possible. Instead of just reloading the last website, we should restore the last state.
Can I work on this issue?
@brampitoyo There's one technical constraint here (maybe, depends on the implementation): We may need to reload/restore some things to get back to the session - meaning we won't have a rendered version of the website immediately available when restoring the tab. So the animation may not look as nice as in your mock. :)
Can I work on this issue?
This is not part of a milestone yet - and potentially a rather complex issue. I suggest picking something from the list of "help wanted" issues. We also have a bunch of things to work on in our android-components repository - if this is interesting to you: https://github.com/mozilla-mobile/android-components/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22
@pocmo wrote:
[…] we won't have a rendered version of the website immediately available when restoring the tab.
I’d be okay if the restored tab shows only a white background and a loading indicator – as long as the URL bar shows the correct URL.
So the animation effect is no longer ‘unfreeze’ (e.g. like a restored VM), but more like ”here’s your last opened site, wait a bit for it to load”.
Can't estimate yet, needs a breakdown.
@bbinto when should we spend the time doing a breakdown?
@brampitoyo I was just wondering: How does this work with multiple tabs? Do we restore all of them? Can you undo closing a single tab via back button?
@Sdaswani - We should probably chat with the team how much time we need to allocate roughly for issues that need to be broken down (see upcoming retro).
My general gut feeling is that the feature/issue is not that urgent (over other features), so I can hold off on that until we have a plan how to do breakdowns.
@bbinto i think most breakdowns are probably a S (.5 to 1 day of work).
Breakdown should happen for 6.0 sprint (no real urgency)
@pocmo wrote:
@brampitoyo I was just wondering: How does this work with multiple tabs? Do we restore all of them? Can you undo closing a single tab via back button?
We should restore all the tabs in the session that was just deleted – restoring as much as possible, essentially.
I don’t think the back button should be used for an “Undo” action. If the user doesn’t click “Undo”, then the Back button would just quit the app (rather than restore the previous session).
Oh, sorry, what I meant was:
- Open a website (tab A)
- Open a new tab by long-pressing a link (tab B)
- Click back button
- -> We close the tab A and you are back in tab B.
Is this something we would want to allow to undo too?
@pocmo Right. When a tab is closed via a back action, should we show a snackbar that says “Tab closed”, and then allow the user to undo it?
I think that this isn’t necessary, actually. What do you think?
I think that this isn’t necessary, actually. What do you think?
Yeah, I'm okay with that decision. I just wanted to make sure we are explicit about that. :)
- [ ] Add "undo" action to snackbar
- [ ] Implement undo based on scope.
- [ ] UX / animation for "reverse" action detailed here
- [ ] Add telemetry probe for undo action
@bbinto Are you working on this? If not then I would like to work on this. Thanks