-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Popup causes navigation back from a redirected page #4595
Comments
I adjusted the test page a little to rule out other issues: http://jsbin.com/ivifos/4/ |
Another example of this issue: http://jquerymobile.com/test/docs/forms/selects/custom.html Open any of the custom select menus (except the "your state" long list example) and click outside the menu to close it without selecting something. You will be redirected to http://jquerymobile.com/test/docs/forms/selects/ |
@uGoMobi - I think this is because the custom select triggers a hashchange when (opening/)closing, which is not blocked (ignoreNextHashchange is only "un-set" when the dialog closes... I assume) and therefore the hashchange is passing through $.mobile.changePage landing at the "no to defined" option, which loads the first page. As a workaround I'm setting flags whenever a popup/custom select or in page dialog is open to preventDefault() hashchanges being triggered from closing elements. I also asked @gabrielschulhof about adding a role to the data.options passed along with every hashChange event. If there was
Then it would be easy to check the incoming hashChange event data for the role and block falsely triggered backwards transitions. Maybe the role can replace ignoreNextHashChange altogether as a global setter. |
@uGoMobi: thinking about this some more. Right now popups, custom selects and dialogs all use #&ui-state=dialog as url extension, when semantically only dialogs are state=dialog. Maybe this is another entry point for setting a widget specific flag on triggered events. |
@uGoMobi - The custom select double- This bug, OTOH, is not specific to popups. Look at http://jsbin.com/iqogin/21 ... Whether you open a popup or a dialog, it goes back to page-0. |
@frequent - The Meanwhile, I'll try some ideas for this particular problem. |
@gabrielschulhof - I have popups working more or less with a fix. Once in a while one popup escapes, but most of the times I can catch them. This is what I'm doing when opening popups (example from a project):
So whenever a popup opens I add selDiaPopBlock to the html element and on pagebeforechange, I'm checking:
Whenever a popup closes I'm cleaning up HTML:
More or less takes care popups. If I could find a way to detect a custom select or dialog firing (not so easy ...), I would also just the blocker class (after all, it's name selectdialogPopupBlock). I have fiddled with photoswipe a little and changed their dialog hashkey from popup to gallery and am now using this to block their hashChanges:
Maybe usable. |
We already have handlers for the case where |
The fundamental issue is that, given the navigational sequence below,
... where when the dialog issues This is incorrect. The page that should be displayed is, of course, the last page that was loaded without hash change (enclosed in To achieve this, we need to
and 2 a. Create a navigation policy such that changeHash: false entries are to some extent "children" of the last known changeHash: true entry, and it is the last child that will be switched to upon xor 2 b. Modify the dialog's and the popup's close method to behave similarly to the I'm leaning towards 2 b. It'd be nice to get the opinion of one @johnbender on this issue :) |
@gabrielschulhof: Is the _handleHashChange behavior you are talking about the "no to defined" option? This is one piece of "hashChange" I would like to get rid of if I could :-) |
What I'm talking about is this: Since you've added the page with changeHash: false, when the dialog goes window.history.back(), _handleHashChange will get the hash of page-0, because page-1 did not have a hash since you added it with changeHash: false. So, the nav dutifully goes back to page-0. Currently, I can't find a good place where to add a special case saying "if you're coming back from a dialog then go to the previous page in urlHistory, not to the page identified by the hash given to you in _handleHashChange". |
How about querying the urlHistory for role? (Without looking into any code), when I'm opening a dialog I create an entry in the urlHistory, which also saves settings role. So when closing the dialog and going back, one would have to check for the role of the last urlHistory entry. If it has a role="dialog" we should be tryring to go back from the dialog and you could tap in and set the backwards transition accordingly. Makes sense? |
We've agreed that we cannot currently add a special case for going back to a page that was added with changeHash: false. |
I found an easy solution. After traveling to a page through a "changeHash=false" link, simply replace the last history item.
I hope this helps someone. |
Any updates on this issue i have a similar problem. One more extra problem for me is that when a option is selected from drop down and enter key is pressed simultaneously it acts like a browser history back. |
Popup (or selectmenu) causes navigation back in history when use
$.mobile.changePage(..., { changeHash: false})
in navigation to a page (a redirected page) that contains such widget.Windows 7 SP1 x64 + Chrome 19.0.1084.56 m:
selectmenu
-> Here will be redirection to Page-0(from #issues 4563)
The text was updated successfully, but these errors were encountered: