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

Ionic 2: iOS navbar height too large when component with button+badge inserted. #7106

Closed
daveshirman opened this issue Jun 28, 2016 · 5 comments

Comments

@daveshirman
Copy link

daveshirman commented Jun 28, 2016

Short description of the problem:

If you declare a custom component with a button that contains a badge or an icon and import it into a navbar, the height of the component is too large, causing the navbar to swell in height on iOS.

What behavior are you expecting?

Navbar height is not affected, component height is correct.

Steps to reproduce:

  1. Make a component with a button containing a badge or an icon (see code block).
  2. Import that component into the page template navbar.
  3. Observe swollen navbar.

custom-component template:

      <button>
          <ion-badge complete>3</ion-badge>
      </button>

page navbar template:

<ion-header>
  <ion-navbar>
    <button menuToggle>
      <ion-icon name="menu"></ion-icon>
    </button>
    <ion-buttons end>
      <custom-component></custom-component>      
    </ion-buttons>
    <ion-title>My Jobs</ion-title>
  </ion-navbar>
</ion-header>
// etc...

Result:

screen shot 2016-06-28 at 23 38 26

Which Ionic Version?
2.x

Run ionic info from terminal/cmd prompt: (paste output below)

Your system information:

Cordova CLI: 6.2.0
Ionic Framework Version: 2.0.0-beta.10
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: 5.0.8 
OS: Mac OS X El Capitan
Node Version: v4.3.0
Xcode version: Xcode 7.2.1 Build version 7C1002 
@jgw96 jgw96 removed the menus label Jun 29, 2016
@brandyscarney
Copy link
Member

This is caused by the bar-button classes not applying since you are nesting the button in another component. Issue #5927 was created for this, there's a workaround to add the category to the button. In your case something like this:

  <button category="bar-button">
      <ion-badge complete>3</ion-badge>
  </button>

Thanks!

@daveshirman
Copy link
Author

Great, thanks.

@daveshirman
Copy link
Author

Hi @brandyscarney this issue has regressed with the removal of the category attribute.

I have update my html to be:

<button ion-button icon-only (click)="showNotificationsModal()">
    <ion-icon *ngIf="notificationsCount == 0" name="cloud-upload"></ion-icon>
    <ion-badge *ngIf="notificationsCount > 0" color="complete">{{notificationsCount}}</ion-badge>
</button>

But now it looks like this:

screen shot 2016-10-05 at 12 39 33

@manucorporat
Copy link
Contributor

@daveshirman
try this:

<button ion-button="bar-button" icon-only (click)="showNotificationsModal()">
    <ion-icon *ngIf="notificationsCount == 0" name="cloud-upload"></ion-icon>
    <ion-badge *ngIf="notificationsCount > 0" color="complete">{{notificationsCount}}</ion-badge>
</button>

Now category is passed like this: ion-button="bar-button"

@daveshirman
Copy link
Author

Perfect. Thank you.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants