Skip to content

bug: Long dynamic header titles are cutoff #4661

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

Closed
DavidFrahm opened this issue Nov 23, 2015 · 21 comments
Closed

bug: Long dynamic header titles are cutoff #4661

DavidFrahm opened this issue Nov 23, 2015 · 21 comments

Comments

@DavidFrahm
Copy link

Type: bug

Platform: ios 7 webview

In multiple Ionic apps where I need to set the view title dynamically, I use this markup:

<ion-view>
    <ion-nav-title ng-bind="category.name"></ion-nav-title>
    <ion-content>
    ...snip...

That works great until it encounters a view title that too long to fit in the bar (easier to test on smaller devices like iPhone 4/5). With a long value, it displays just like one character and the ellipsis.

I fix it by adding this to my scss:

// Longer ion header titles intermittently have crazy large right values on iOS
.platform-ios,
.platform-browser {
  .title.title-center.header-item {
    right: 26px !important;
  }
}

This seems like it might just be an issue with the Angular lifecycle of things, and might not be a clean fix on the Ionic side. (Similar to the issue of why view-title="{{category.name}}" has issues.)

@mhartington
Copy link
Contributor

Codepen demo please

@mhartington mhartington added the needs: reply the issue needs a response from the user label Nov 23, 2015
@DavidFrahm
Copy link
Author

http://codepen.io/davidfrahm/pen/vNPoVa

Make the viewport really small, reload the page, then click the button to navigate to the view with long/broken title

ionic-issue-4661

@Ionitron Ionitron removed the needs: reply the issue needs a response from the user label Nov 23, 2015
@adamhughes86
Copy link

Any news on this?

Same issue as #945 which was reopened. No feedback on that one either

@zanemcca
Copy link

+1

@leizard
Copy link

leizard commented Mar 11, 2016

+1. I met the same problem

@thanhnh-infinity
Copy link

+1 . Yes, this issue has no longer fixed completely for long time

@Louis-P
Copy link

Louis-P commented Mar 22, 2016

+1

1 similar comment
@dilignt
Copy link

dilignt commented Mar 24, 2016

+1

@jgw96 jgw96 added css labels Mar 24, 2016
@jgw96
Copy link
Contributor

jgw96 commented Mar 24, 2016

thanks @DavidFrahm for the codepen! We are definitely gonna have to take a look at this. It looks like the title is overflowing way too early, is that the issue you all are describing?

@DavidFrahm
Copy link
Author

@jgw96 Yes, that sounds like one way to look at it. Honestly, it's been a long time and I've just become used to it and always use the CSS workaround in all my projects.

@taigeair
Copy link

taigeair commented Apr 7, 2016

Happens for me too

@adamdbradley adamdbradley removed the bug label Apr 12, 2016
@johnfakeacc
Copy link

+1 any workarounds?

@zanemcca
Copy link

Here is my workaround.

//Hack to fix squashed title on iOS
// ionic issue #4661
.platform-ios {
  .title.title-center.header-item {
    left: 49px!important;
    right: 49px!important;
  }
}

.platform-android {
  .title.title-left.header-item {
    right: 68px!important;
  }
}

@johnfakeacc
Copy link

Great thanks!

@Bouzmine
Copy link
Contributor

Only problem I find with this workaround is that long titles will overlap the "Back » button. Would there be a way to do like native, to make header title go to the left (screenshot 2).

Screenshot

@zanemcca
Copy link

What screenshot? I am having no issue with back button overlap with this solution.

danbucholtz added a commit that referenced this issue May 6, 2016
ion-nav-title will fill up available space

#4661
@danbucholtz
Copy link
Contributor

Hello everyone,

This fix will be in the nightly build tonight.

Full disclosure - there are several fixes we could do make with the header, this is a start. If you dynamically add buttons next to this, you may still run into problems. That is a separate issue that we need to fix as well.

Please test and let me know how it goes. The easiest way to test is to download the nightly ionic.bundle.js file and place it in your project's lib/ionic/js directory, and then make sure your html file is importing the file correctly.

If needed, we'll reopen this.

Thanks,
Dan

@magaliegimenes
Copy link

Hello,
Thanks for this fix, I waited for it but in my case it does not work. So, I searched for what was happening and I found out that on the method "self.titleTextWidth", if I comment the break inside the "for" loop (js/angular/controller/headerBarController.js, line 1154), it works (As the element retrieved is always the one in my previous page with the current code).
Maybe the cause of the problem is that I always have tabs at the bottom of my page and they are always here after navigation.
Thanks in advance.
Regards
Magalie

@sinedied
Copy link

The issue is actually that it use the first element with the nav-bar-title class, but it can be the one hidden (cached) from the previous screen, used for animations. A proper fix is:

      var children = angular.element(element).children();
      for ( var i = 0; i < children.length; i++ ) {
        var child = angular.element(children[i]);
        if ( child.hasClass('nav-bar-title') && !child.hasClass('hide') ) {
          element = children[i];
          break;
        }
      }

Thanks @magaliegimenes for the hint!

@mdanics
Copy link

mdanics commented Aug 21, 2018

Facing this issue on Ionic 3.9.2 after using the SideMenu starter project

@ionitron-bot
Copy link

ionitron-bot bot commented Sep 20, 2018

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 20, 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