backstack icon indicating copy to clipboard operation
backstack copied to clipboard

Calling popView when there are no views to pop breaks BackStack

Open dominicglenn opened this issue 13 years ago • 2 comments

When I called popView one too many times I got the error 'Error: Popping from an empty stack!' which is correct as I didn't have any views left; but if you try to pushView a new view after having gotten that error it will not push the new view at all, you need to re-instatiate BackStack in order to make it work and use it again.

dominicglenn avatar Aug 02 '12 08:08 dominicglenn

This happens when the stack is popped and there are no more views. I notice if I hit the "back" button in my Web App twice, I am not able to avoid this, even when I tried to use the following:

if(!navigator.viewstack.length<1)
    navigator.popView();

The problem is the view is still animating when I click 'back' the second time, and the length does not get updated until animation stops. Maybe we can check if "animating" or "viewChanging" and prevent further pops.

I think it should check for zero and prevent the stack from popping its last view.

anzorb avatar Oct 14 '12 21:10 anzorb

+1

I have tried all kinds of combinations of tests, but if you tap fast enough, you can get into trouble. Not just blank state trouble, broken non-responsive app trouble.

edit: I have resorted to disabling the back button in viewChanging (pre-transition) then re-enabling it in viewActivate (post transition). Seems OK for now.

devgeeks avatar Feb 17 '13 11:02 devgeeks