question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: hide-back-button hides ion-nav-buttons

See original GitHub issue

Type: <span ionic-type>bug</span>

Platform: <span ionic-platform>all</span>

<span ionic-description>First, a pen: http://codepen.io/nsquimby/pen/ZGQOvY?editors=101

This is probably a lot for this issue, but I just wanted to cover my bases because it doesn’t look like there are any ‘good’ workarounds using the ionic platform at the moment.

My use case is after a user goes through a series of views (setup wizard), the final view provides a link back to my apps home/default state. That default view has hide-back-button="true", and I would expect it would display the ion-nav-buttons including my button with menu-toggle="left", however all nav-buttons are hidden (see Test 2 in pen)

The expected behavior ofenable-menu-with-back-views="false" on the ion-side-menu is to display only the back button OR the left nav buttons (see Test 1 in pen), in which case it’s acting as it should. However, I cannot find a reasonable work-around to hide the back buttons in a view and display other ion-nav-buttons which doesn’t involve outright removing ion-nav-back-button from menu.html (or whatever template with ion-side-menu) and then putting and adding it to every state where I may want a back button. I would expect adding hide-back-button="true"[edit] would hide just the back button, but it also appears to hide the ion-nav-buttons on the left, as in Test 2 in the pen

Workarounds I’ve tried include calling $ionicHistory.$clearHistory() (see Test 3 in pen) each time the user clicks a link back to the /app/home state, and I expect /app/home would be treated as the root state in history, and therefore, not show the back button, but the back button still hides the other ion-nav-buttons (because menu with back buttons are disabled) and because the view history has been cleared, the back button does nothing.

Some users may want to allow a back button from parent state to a child state (Test 4 in pen, which originally brought this bug to my attention), so changing the default behavior may be problematic. A few solutions which would break fewer peoples apps would be: prevent hide-back-button from hiding all the ion-nav-buttons on the left side (in this case, my button with menu-toggle=“left”), OR, provide a configuration option in $ioniNavBarDelegate to define the root state at which ion-back-button never appears.</span>

<span is-issue-template></span>

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
cpampcommented, Sep 23, 2016

I’m surprised that this is “working as intended.” IMO, hide-back-button should do exactly as it says, hide the back button. Not the menu button as well.

3reactions
premiumFryecommented, Jun 12, 2015

Thanks, can confirm that works, but that’s not a solution I had in mind because it requires declaring nextViewOptions on every link back to the home state requiring a lot more code 😕. A workaround i’ve implemented is sticking this in the controller for the home state:

$scope.$on('$ionicView.beforeEnter', function (e,config) {
  config.enableBack = false;
});

It feels awfully hacky, but it works – see here: http://codepen.io/nsquimby/pen/PqjxxV?editors=101

Conveniently, this also works when cache-view='false' because it doesn’t depend on the controller getting fired again, as well as on nested states, because it doesn’t alter history.

Ultimately I think that when enable-menu-with-back-views="false" on your side menu template, hide-back-button="true" on your ‘home’ state template should not hide the menu/sandwich button along with the back button, and I don’t think that’s the behavior people expect.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to remove back button in ionic header only in one page
For latest Ionic versions try using <ion-navbar hideBackButton >. This should work.
Read more >
Keep main header bar & disable back button on - Ionic Forum
yes i have tried, hides the button but doesn't show the left and right nav icons. I have tried to put a plunker,...
Read more >
hideBackButton attribute hides the menuToggle button too
Hi again, I've reproduced the issue in this plunker. When you use this.nav.push(Page1) the page is pushed to the navigation stack, but the...
Read more >
iOS 14 Navigation back button menus | Apple Developer Forums
The back button menu cannot be disabled, as long as the navigation bar shows its native back button, the menu is available. You...
Read more >
Angular: Hide Navbar Menu from Login page - Loiane Groner
In this first example we will have only one page layout and we will verify if the user is logged in and use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found