Closed edchat closed 12 years ago
I fix this one on desktop. @edchat, would you please verify whether click the back button on iOS and android cause two popState event?
I was able to verify that I do get 2 calls to onPopState in the History controller for iOS, I also found that on Android, if the hardware back button is pressed it works correctly, but if the Back button on the app is touched it does go back twice, but I was not able to see the console output to verify that onPopState was called twice on android.
use console.log(...) in the js code,then connect an Android device by adb. In the eclipse device view, select the android device; in the logcat view, add a filter with application name "browser", then you can check the logs on android.
@edchat will test.
I was wondering if that might not come from the fact we are using HTML5 history in the app. There are issues with that on some iOS and Android versions right? So why are we using it?
HTML5 history APIs can take parameters and more effective than add parameters in url hash change. Additional, use these API can let browsers to maintain the history queue. browsers will support HTML5, see here http://caniuse.com/#search=history. Chrome browser on Android is available now.
@eric-wang
two points:
this problem comes from the fact that when we are back from the repeat page we are history.back() is first call from dojox/mobile code and then it enters the following code of the EditTodoItem view which performs an additional back call:
signal = on(dom.byId("detail_back"), "click", lang.hitch(this, function(){
this._backFlag = true;
history.back();
}));
I'm not sure why yet (in particular why only on mobile) but that's clearly the reason of the double back behavior.
If instead of just quickly pushing the back button you press it for a longer time, the behavior is correct (i.e. back only one time).
ok, the problem is coming from a clash between the synthetic click event listened to by the dojox/mobile standard back button used in the Repeat view and the fact that in the EditTodoItem view we are listening to the DOM click event to react. The 2nd back button never gets the synthetic click event, but get the DOM one for a reason I don't understand. Maybe @edurocher could comment and see if there is not a problem in dojox/mobile here but the workaround is very easy: it is to be be consistent and only listen to synthetic events.
I will modify EditTodoItem.js for this (not only the back button, for all events we listen to in this view), more generally all the todoApp should be reviewed be consistent and listen to dojox/mobile synthetic events instead of DOM events.
To recreate the problem, Select and item, and select the Repeat, select something on the Repeat page and touch Back. It will go back to the Details page briefly before going back again to the List page. This does not happen on desktop browser with Chrome or Firefox.