Navigation Menu

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: Tab page lost back navigation #5351

Closed
icarus31 opened this issue Feb 5, 2016 · 24 comments
Closed

bug: Tab page lost back navigation #5351

icarus31 opened this issue Feb 5, 2016 · 24 comments
Assignees
Labels
ionitron: v3 moves the issue to the ionic-v3 repository

Comments

@icarus31
Copy link

icarus31 commented Feb 5, 2016

Type: bug

Ionic Version: 2.x

Platform: all

Before my tabs page, I have few other regular pages and the "< Back" is always present at the left corner.

When reaching my tabs page, I am losing the "< Back" in my header. Why?

How do I get the back button back when using tabs in Ionic2?

For now, I am putting the tabs inside an ion-content

@Ionitron Ionitron added the v2 label Feb 5, 2016
@brandyscarney brandyscarney added this to the 2.0.0-beta.11 milestone Feb 11, 2016
@brandyscarney
Copy link
Member

This is by design because each tab has it's own stack. We will have to put some thought into adding this as an option so I put it in a future milestone.

@kevinclarkra
Copy link

I was wondering about this too, I was trying to build something in Ionic v2 with a sidebar menu and tabs. I put the generic List page as one of the tabs [root]. When I click on a list item, it doesn't display the Back link.

@kevinclarkra
Copy link

I don't know if there is a great way to combine a side menu with tabs or if I'm doing it right. My implementation is to make a TabsPage page that imports the 3 pages I need (as tabs). THose three pages I have taken out the < ion-navbar > from the template so they don't see two side menus.

@brandyscarney
Copy link
Member

@kevinclarkra The Ionic conference app uses a side menu and tabs, maybe that will help: https://github.com/driftyco/ionic-conference-app

The detail pages need to have the navbar though in order to show a back button.

@kevinclarkra
Copy link

@brandyscarney Thanks for the link! I will look into that. I am still trying to wrap my head around the Angular2/Ionic2 but it looks promising.

My other question - I did a new project with and without TS...the javascript looks exactly the same? I guess I am a little confused by this, the only difference is the .ts extensions.

@brandyscarney
Copy link
Member

Yeah it is known that it isn't using valid JS, we are working on it. There is an issue for it here: #5493 and here: #5486

@kevinclarkra
Copy link

@brandyscarney Ahh. I was wondering about that. I like the annotations, so I probably should be using the TypeScript version instead then. Thanks for all the work you've guys done with Ionic2, I've considered Ionc 1, Framework7, Famo.us (with Angular or something), and Onsen but am really intrigued by the possibilities with Ionic2 plus the fact it has ios and Material design was the deciding factor.

@kevinclarkra
Copy link

Btw, pulled down the Speakers app and built it, saw how it works, copied the tabs over to mine...works, brilliant! I was getting frustrated there but now I made progress I feel better. Thanks again for the link

@brandyscarney
Copy link
Member

@kevinclarkra That's so great to hear! Thank you. Glad you got it working. 😄 There are also a lot of helpful community members on our forums: https://forum.ionicframework.com

@jgw96
Copy link
Contributor

jgw96 commented Apr 14, 2016

Closing this as it seems it has been fixed! If it hasn't feel free to comment and i will happily reopen! (:

@jgw96 jgw96 closed this as completed Apr 14, 2016
@brandyscarney
Copy link
Member

The initial issue still exists, it's not fixed yet.

@zakton5
Copy link
Contributor

zakton5 commented Jun 16, 2016

I know that this has to be dicussed among the ionic team, but here is a solution proposal:

the getPrevious() function in nav-controller.ts could be changed to something like this:

getPrevious(view: ViewController): ViewController {
    var previous = this.getByIndex(this.indexOf(view) - 1);
    if (!previous) {
      var parent: NavController = this.parent;
      return parent ? parent.getByIndex(parent._views.length - 1) : null;
    } else {
      return previous;
    }
  }

Basically, if the current nav stack (which would be the tabs stack) has no previous view, then check if it has a parent nav stack. If it does, then return the last view in the parent nav stack.

Note: To be clear, this code won't actually work. It's just an example/idea.

@barocsi
Copy link

barocsi commented Jul 19, 2016

+1

@lonwi
Copy link

lonwi commented Oct 20, 2016

I think I have the same problem with RC1. I will just use modal instead to display profile details.

@lonwi
Copy link

lonwi commented Oct 20, 2016

Unfortunately, the tabs with modal does not close properly as well. The tabs stay visible after the this.viewCtrl.dismiss(); from the tab level.

After few tries I noticed that if you put the header above the ion-tabs the back button appears as it supposed to.

Tried this with modal way and it dismiss correctly as well.

You need to leave the ion-header in each tab as well in order to push the ion-content down. I would be useful to have something like "has-header" on ion-content so there is no point of adding empty header to the tab.

so my tabs.html looks like that

<ion-header> <ion-navbar color="blue-dark"> <button ion-button menuToggle color="white"> <ion-icon name="menu"></ion-icon> </button> <ion-title></ion-title> </ion-navbar> </ion-header> <ion-tabs color="blue-dark" tabsPlacement="bottom" tabsHighlight="true" tabsLayout="icon-hide"> <ion-tab [root]="profileTab1Root" tabTitle="Profile" tabIcon="ios-contact" [rootParams]="user"></ion-tab> <ion-tab [root]="profileTab2Root" tabTitle="Details" tabIcon="ios-information-circle" [rootParams]="user"></ion-tab> <ion-tab [root]="profileTab3Root" tabTitle="Looking for" tabIcon="ios-contacts" [rootParams]="user"></ion-tab> </ion-tabs>

and the tab-1.html looks like

<ion-header> <ion-navbar color="blue-dark"> </ion-navbar> </ion-header> <ion-content> <div class="user-profile" *ngIf="user"> {{user.firstName}} </div> </ion-content>

And it works fine.

@jstoup111
Copy link

Any status on this?

I've tried @lonwi example, but the child pages in the tab don't navigate properly. I.E.

Parent -> Tab -> Another Page on first tab ->

Clicking the back button navigates me all the way back to the parent.

@douglasjva
Copy link

@brandyscarney Some workaround was found for this problem?

@matoos32
Copy link

matoos32 commented Apr 1, 2017

Here is a demo solution that uses @icarus31 's idea of "tabs inside an ion-content"
Tabs are wrapped inside a basic component, which gets the back button. I went further to hook the tabs' ion-select event. When tabs are selected the event is double-dispatched to the wrapper, providing the wrapper with the tab name . The wrapper then sets the tab name in the nav bar title.

https://github.com/matoos32/ionic-2-tabs-page-with-back-button

Happy coding!

@dalezak
Copy link

dalezak commented Oct 9, 2017

@matoos32 thanks for sharing the demo solution, I was able to get it working but ran into two issues.

One, I'm getting extra padding or margins at the top of tabs between the navbar, looks like same height as the statusbar.

tabs-padding

Two, upon clicking Back and returning to Home, the view is initially blank for a second before it redraws.

Any idea on the cause or a solution to either of these issues? /cc @icarus31

@matoos32
Copy link

@dalezak :

One, I'm getting extra padding or margins at the top of tabs between the navbar, looks like same height as the statusbar.

It uses generated code in the landing page and boilerplate code for the wrapper and tabs. Maybe the standard CSS or your icon height?

Two, upon clicking Back and returning to Home, the view is initially blank for a second before it redraws.

Looks like an iOS specific issue but seemingly unrelated to the demo itself (see our discussion here).

@dalezak
Copy link

dalezak commented Oct 28, 2017

Thanks @matoos32, I created an issue related to the extra padding #13229, looks like it's an Ionic with iOS11 issue.

@matoos32
Copy link

I added new commits that migrate the sample code to Angular 5 and Ionic 3.9.2. Misnomer to call it "Ionic 2" now but I don't want to break any links anywhere. You can still access the Ionic 2 version by looking up the related tag.

@adamdbradley adamdbradley added the ionitron: v3 moves the issue to the ionic-v3 repository label Nov 1, 2018
@ionitron-bot
Copy link

ionitron-bot bot commented Nov 1, 2018

Thanks for the issue! We have moved the source code and issues for Ionic 3 into a separate repository. I am moving this issue to the repository for Ionic 3. Please track this issue over there.

Thank you for using Ionic!

@ionitron-bot
Copy link

ionitron-bot bot commented Nov 1, 2018

Issue moved to: ionic-team/ionic-v3#44

@ionitron-bot ionitron-bot bot closed this as completed Nov 1, 2018
@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Nov 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
ionitron: v3 moves the issue to the ionic-v3 repository
Projects
None yet
Development

No branches or pull requests