Skip to content
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

bug: Navigation issue in sidemenu starter project #4038

Closed
chriseen opened this issue Jul 5, 2015 · 6 comments
Closed

bug: Navigation issue in sidemenu starter project #4038

chriseen opened this issue Jul 5, 2015 · 6 comments

Comments

@chriseen
Copy link

chriseen commented Jul 5, 2015

Type: bug

Platform: all

I am using the latest version of Ionic (v1.0.1) to create a sidemenu starter project. Unfortunately I found an annoying issue in this "standard" template.

  • Create a sidemenu starter project

    $ ionic start myApp sidemenu

  • Run this project. You will see Playlists page by default. Please don't do anything... just open side menu by swiping.

  • Tap on Playlists from side menu. (I know Playlists was opened already) Side menu disappears and Playlists page will appear again.

  • Tap on any item, for example, Dubstep.

  • You will be redirected to single playlist page. But you won't see Back button in navigation bar, as if navigation history was cleared. In this case, Back button should appear because new page (Dubstep) is pushed to navigation stack.

Navigation system and back button works well when Playlists page is opened only once via side menu. Issue happens when you access this page twice. (continuously)

I cannot actually believe this standard / well-known seed project includes such a stupid issue. And it's actually killing me.

@chriseen
Copy link
Author

chriseen commented Jul 5, 2015

It seems this issue is actual in some newer versions of Ionic, but I also found this doesn't happen in v1.0.0-beta.14

@gotojmp
Copy link

gotojmp commented Jul 7, 2015

I also found this bug, and I temporarily add this for bugfix:

angular.module('starter.controllers', [])
.controller('MenuCtrl', function($scope, $ionicModal, $timeout, $rootScope, $ionicHistory) {
$rootScope.$on('$ionicSideMenuClose', function (e, side) {
if (side == 'left') {
$timeout(function () {
$ionicHistory.nextViewOptions({
historyRoot: false,
disableAnimate: false,
expire: null
});
}, 100);
}
});
});

@nicky-song
Copy link

Thanks for your response, @gotojmp. It worked. However, I am actually planning create a pretty complicated project. I am afraid this hack will cause some unexpected troubles in my project. Is there any other official fixes or releases for this?

@stan-kondrat
Copy link

I have same bug in my production project. Problem in menuClose.

When you click on menu, nextViewOptions historyRoot set true.
If you click on menu of the same page, page not redirected, but any other new open page historyRoot set true.

IonicModule
.directive('menuClose', ['$ionicHistory', function($ionicHistory) {
  return {
    restrict: 'AC',
    link: function($scope, $element) {
      $element.bind('click', function() {
        var sideMenuCtrl = $element.inheritedData('$ionSideMenusController');
        if (sideMenuCtrl) {
          $ionicHistory.nextViewOptions({
            historyRoot: true,
            disableAnimate: true,
            expire: 300
          });
          sideMenuCtrl.close();
        }
      });
    }
  };
}]);

@stan-kondrat
Copy link

If in your project menu-close with href, like in ionic-starter-sidemenu <ion-item menu-close href="#/app/playlists">, this fix for menuClose directive:

IonicModule
.directive('menuClose', ['$ionicHistory', function($ionicHistory) {
  return {
    restrict: 'AC',
    link: function($scope, $element, $attr) {    // <--- add $attr
      $element.bind('click', function() {
        var sideMenuCtrl = $element.inheritedData('$ionSideMenusController');
        if (sideMenuCtrl) {

          var currentView = $ionicHistory.currentView();     // <--- add line
          var currentViewUrl = "#" + currentView.url;     // <--- add line
          if( $attr.href !==  currentViewUrl ) {     // <--- add line
            $ionicHistory.nextViewOptions({
              historyRoot: true,
              disableAnimate: true,
              expire: 300
            });
          }     // <--- add line

          sideMenuCtrl.close();
        }
      });
    }
  };
}]);

But this check href of current view, will not fix <ion-item menu-close ng-click="login()">

Another solution replace menu-close with menu-toggle
#2802 (comment)

@mhartington
Copy link
Contributor

Closing as a duplicate of #4132

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants