-
Notifications
You must be signed in to change notification settings - Fork 13.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nav-clear in sidemenu breaks navigation #1043
Comments
The problem in this specific codepen is that the href link given by your navClear element doesn't go to an actual page. Therefore, the next view after that takes the navClear's viewOptions. To put it more simply .. navClear is trying to say 'hey next page, don't animate or show a back button'. Then you click it, and it tells that to .. no page! Because the href doesn't go anywhere. So then the page after that gets no view and back button. |
Yep, I had a wrong path set for the href in the sidemenu in this codepen. But if I change it to the correct path(#/menu/page) the problem still persists? |
Hm.. it's still the same problem internally, the page isn't actually changing because we're going to the link we're already on. However, that is not what is expected from the directive and should be fixed. Will leave open, thanks. |
I'm pretty new to Ionic but never the less - here's my 5 cents. :) This is the current directive:
I'm thinking that either you wan't nav-clear or you don't - for the whole ion-side-menu. So maybe this could work: In case nav-clear is set on ion-side-menu it could wait for $stateChangeStart to be emitted (while menu is open) before it calls $ionicViewService.nextViewOptions()? This way it never never disable animation and backbutton unless the state is actually changing. If would then be something like this:
|
Good research @michaelkrog! But what if the navClear is clicked, the $stateChangeStart is listened for, and then no state change happens immediately (same href problem again)? Then the next state change actually ends up happening a lot later, and we have the same problem. Or what if the side menu is open and someone changes state programatically? Possible solution off the top of my head: force nav-clear to say which state it is targetting, via |
Thx @ajoslin
|
I can confirm that changing the navClear-directive to keep an eye on ui-sref indeed can work. I changed the linker in the directive to this:
This fixes my issue but is of course not a full resolution. This fix currently requires:
|
After some thought, I think really the most reliable way to get around the problems while still using our current infrastructure is a setTimeout. The setTimeout still has a few edge cases that are problematic, but it is the best I could think of without having to get really complicated. var unregisterListener;
function listenForStateChange() {
unregisterListener = $scope.$on('$stateChangeStart', function() {
$ionicViewService.nextViewOptions({
disableAnimate: true,
disableBack: true
});
});
setTimeout(unregisterListener, 300);
}
$element.on('click', listenForStateChange); Some future work needs to be done on a proper solution, though.. And this will still break if the state change fails. |
I think this issue has been re-introduced in ionic 1.0.0 or 1.0.1 (updated from RC5) in a way. I have a situation where, in the left navigation I have a href to
EDIT: Correction, it doesn't matter what the next URL is, it will still clear the history stack and make the next page root. Sorry for the confusion. |
I too have this problem with nav-clear. |
+1 |
This is fixed in the nightly builds. |
Oh great, I'll check that out. Thank you! |
Thank you. |
有点牛逼 |
If i have sidemenu (abstract state: menu), a page (state: menu.page) and a subpage (state: menu.page.subpage) and I use nav-clear on links in the sidemenu to disable animations when the links are clicked in the sidemenu, then subsequent navigation seems to break.
The way I see it is:
I made a codepen here: http://codepen.io/anon/pen/HLaDu/
Try to go to subpage and then back. It works fine - back and forth several times. But as soon as I open the sidemenu and click the link to go to close the menu again, then it is broken.
If I remove nav-clear from the link in the sidemenu, then things works fine - but leaves me with the animation-between-views problem which nav-clear was supposed to fix.
(Using beta 1)
The text was updated successfully, but these errors were encountered: