bug: hide-back-button hides ion-nav-buttons
See original GitHub issueType: <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:
- Created 8 years ago
- Comments:8 (4 by maintainers)
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.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: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.