cjolif / dojo-todo-app

Dojo ToDo App
Other
28 stars 15 forks source link

Back from subchild on Details goes back two pages on ios or android device. #82

Closed edchat closed 12 years ago

edchat commented 12 years ago

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.

eric-wang commented 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?

edchat commented 12 years ago

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.

eric-wang commented 12 years ago

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.

cjolif commented 12 years ago

@edchat will test.

cjolif commented 12 years ago

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?

eric-wang commented 12 years ago

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.

cjolif commented 12 years ago

@eric-wang

two points:

cjolif commented 12 years ago

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.

cjolif commented 12 years ago

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).

cjolif commented 12 years ago

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.