ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

No padding for statusbar (on iOS) when nav-pushing inside a modal

Open zmbc opened this issue 10 years ago • 45 comments

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.

img_2079

What behavior are you expecting?

Like all other navbars, this one should leave enough space for the statusbar.

Steps to reproduce:

  1. Open a modal.
  2. Within the modal, call NavController#push with 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

zmbc avatar Sep 21 '16 02:09 zmbc

same issue here. i solved it by not pushing the new page but presenting it as a second modal.

comfortme avatar Sep 21 '16 18:09 comfortme

Hello all! Thanks for using Ionic!. I am happy to report that I can no longer reproduce this issue with RC0. Thanks!

jgw96 avatar Sep 28 '16 17:09 jgw96

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.

msalcala11 avatar Oct 08 '16 16:10 msalcala11

Same issue here.

CyrisXD avatar Oct 09 '16 03:10 CyrisXD

Can confirm this issue as well

royipressburger avatar Oct 09 '16 14:10 royipressburger

yes this issue still exists. please reopen

comfortme avatar Oct 10 '16 14:10 comfortme

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();
  }

manucorporat avatar Oct 10 '16 15:10 manucorporat

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.

ghenry22 avatar Nov 08 '16 03:11 ghenry22

Still exists. Any simple hacks to prevent this?

EralpB avatar Nov 12 '16 16:11 EralpB

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>

ghenry22 avatar Nov 13 '16 02:11 ghenry22

Still having this issue. Will this be fixed soon?

mrhirsch avatar Nov 29 '16 00:11 mrhirsch

@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.

kamok avatar Nov 30 '16 16:11 kamok

@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.

kamok avatar Mar 09 '17 15:03 kamok

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 avatar Apr 04 '17 15:04 timvandijck

@timvandijck Can you provide an example?

kabus202 avatar Apr 05 '17 10:04 kabus202

@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');
    }
}

timvandijck avatar Apr 05 '17 12:04 timvandijck

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

wbhob avatar May 01 '17 02:05 wbhob

Still present in ionic-angular 3.3.0. Any way to fix it?

vosecek avatar May 29 '17 08:05 vosecek

@manucorporat Could you please reopen this issue? Open modal in page open by navController.push() cause same situation as pictured in first post.

vosecek avatar Jun 07 '17 09:06 vosecek

Yep please re-open

joewoodhouse avatar Jun 08 '17 11:06 joewoodhouse