No padding for statusbar (on iOS) when nav-pushing inside a modal
Short description of the problem:
The navbar can overlap the statusbar on iOS, when a new page is pushed using NavController#push from inside of a modal. See screenshot.

What behavior are you expecting?
Like all other navbars, this one should leave enough space for the statusbar.
Steps to reproduce:
- Open a modal.
- Within the modal, call
NavController#pushwith any page.
Which Ionic Version? 2
Repo that shows an example of your issue
https://github.com/zmbc/statusbar
Go to the list, open an item, then hit "Push Something".
Run ionic info from terminal/cmd prompt: (paste output below)
Gulp version: CLI version 3.9.1
Gulp local: Local version 3.9.1
Ionic Framework Version: 2.0.0-beta.11
Ionic CLI Version: 2.0.0-beta.32
Ionic App Lib Version: 2.0.0-beta.18
ios-deploy version: 1.8.6
ios-sim version: 3.1.1
OS: Mac OS X El Capitan
Node Version: v6.3.0
Xcode version: Xcode 7.3.1 Build version 7D1014
same issue here. i solved it by not pushing the new page but presenting it as a second modal.
Hello all! Thanks for using Ionic!. I am happy to report that I can no longer reproduce this issue with RC0. Thanks!
This bug still exists. This issue can only be reproduced on an actual device/emulator. It won't appear on desktop browsers unless you pass { statusbarPadding: true } to the config variable of IonicModule.forRoot(MyApp, config). I've created a quick repo to demonstrate this issue with RC0 https://github.com/msalcala11/modal-padding-bug.
Same issue here.
Can confirm this issue as well
yes this issue still exists. please reopen
We have to document modals better, we have people working on this right now. @comfortme @royipressburger @CyrisXD @msalcala11 @zmbc You have to create a new ion-nav in order to have navigation inside a modal, just like you do to have navigation in your app.
@Component({
template: '<ion-nav [root]="root"></ion-nav>'
})
export class NavigationModal {
root = ModalFirstPage;
}
// YOUR CONTENT MODAL
@Component({})
export class ModalFirstPage {
}
(...)
presentModalChildNav() {
this.modalCtrl.create(NavigationModal).present();
}
this still doesn't really make sense to me.
I have a page that I will navigate to either from another page OR from a modal depending on where the user is in the app.
When I do a nav.push within the modal it goes to the page, everything transitions nice and works exactly as I want it to. EXCEPT that the statusbar padding does not get applied when I navigate to the page from a modal.
I don't really see how the code snippet above helps me with that at all? This seems like it should be a really simple thing as functionally everything is working AND in one of the earlier betas the statusbar padding was also correctly applied but this was then broken again in a later release.
Note that android does not have any issue with the same code the navigating either from another page or from a modal all is formatted correctly and works just fine, I would expect ios to be the same.
Still exists. Any simple hacks to prevent this?
Apply the following CSS to ion-navbar and ion-title to fix this. I use an ngIf* to only apply it if the platform.is(iOS) as android doesn't need this. This is simply overridden by the default css when opening from another page on iOS so no issues there either.
Also note that any alert / actionsheet / pop over you open from the newly pushed page will open behind the page. You will need to hack the z-index value for those components to be higher than the modal z-index so they are always on top. Given that those things should always be ontop anyway that isn't really an issue.
<ion-navbar *ngIf="globals.isIos" style="height:calc(44px + 20px); min-height:calc(44px + 20px); padding-top:20px;">
<button ion-button menuToggle>
<ion-icon name="menu"></ion-icon>
</button>
<ion-title style="padding-top:14px !important;">{{selectedItem.name}}</ion-title>
</ion-navbar>
Still having this issue. Will this be fixed soon?
@mrhirsch There's a similar issue on here. Check it out. It's not fixed, but @manucorporat asked for a repo example that I provided there so hopefully they're working on it.
@ghenry22
The way you're doing that padding is not a good way. Do not use *ngIf to hide navbars based on platform types. The calculation for the ion-content subsequently will not take account of the navbar and will cause the entire ion-content to shift up.
Instead, in the app.scss, add the following CSS.
.platform-ios .ios-header {
height:calc(56px + 20px);
min-height:calc(56px + 20px);
padding-top:20px;
}
Then simply in the header that you need this (for me, it's all the pages where I push onto the Tab page), just add class="ios-header".
<ion-header>
<ion-navbar class="ios-header">
</ion-navbar>
</ion-header>
Much DRYer, and without the ion-content issue. Of course, if the Ionic Team looked into this themselves we wouldn't have to go through this pain.
For anyone who is stumbling on this with a popover, this is the same issue.
Regarding the solution: it's not a good idea to go with the CSS-fix approach because you are just masking something that you aren't doing as designed (even if it's a bit of a weird design tbh).
An other solution than the one manucorporat points out is to work with events. I did it like that and it's very simple and clean. Just fire an event in your modal or popover page and listen for it in your "parrent"-page. More on events can be found here: https://ionicframework.com/docs/api/util/Events/
@timvandijck Can you provide an example?
@kabus202 this is an example with a popover:
The page where you are launching the popover:
@Component({
selector: 'page-my-page',
templateUrl: 'my-page.html'
})
export class MyPage {
popover = null;
constructor(public navCtrl:NavController, public popoverCtrl: PopoverController, public events: Events) {
this.events.subscribe('nav:my-other-page', () => {
this.navCtrl.setRoot(MyOtherPage);
if (this.popover) {
this.popover.dismiss();
}
})
}
toggleActionsMenu(event) {
this.popover = this.popoverCtrl.create(PopoverContentPage);
this.popover.present({
ev: event
});
}
}
The page that contains the content of the popover:
@Component({
selector: 'page-popover-content',
templateUrl: 'popover-content.html'
})
export class PopoverContentPage {
constructor(public events: Events) {
}
registerAppliance() {
this.events.publish('nav:my-other-page');
}
}
Yeah, this is still an issue. Also, when you try to swipe to go back, it can sometimes act up and pop the view under the modal. @jgw96
Still present in ionic-angular 3.3.0. Any way to fix it?
@manucorporat Could you please reopen this issue? Open modal in page open by navController.push() cause same situation as pictured in first post.
Yep please re-open