Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone 6+ Mobile safari iOS 8 landscape with tabs open and Bootstrap navbar-fixed-top will not close when open

I have run into a bug with Bootstraps navbar-fixed-top with the iPhone 6+'s mobile safari in landscape on iOS 8. The bug only happens with other tabs open.

Here is how to replicate it:
1) Go to http://getbootstrap.com/examples/navbar-fixed-top/ on your iPhone 6+ in landscape – be sure you have one other tab open
2) Scroll down the page without opening the collapse
3) Once Safari's status bar (the url and tabs) goes away, open the navbar
4) Scroll back up so that Safari's status bar with tabs comes back up
5) Try to close the navbar.

I had this bug in iOS 7, but was able to fix it by adding the viewport minimal-ui meta. I have tested my iPhone 6+, and the 6+ iPhone simulator with the latest version of iOS 8. It appears the tabs are to blame since the regular iPhone 6 doesn't have this problem because the tabs do not show on the status bar. I would imagine this bug goes beyond just Bootstrap though, but applies to any fixed element on the top.

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet" />
<div class="to-sticky navbar-fixed-top">
  <div class="nav-container">
    <div class="navbar">
      <div class="navbar-header">
        <a type="button" class="navbar-toggle btn-secondary btn" data-toggle="collapse" data-target=".navbar-ex1-collapse">
      Main Menu
    </a>
      </div>
      <div class="collapse navbar-collapse navbar-ex1-collapse">
        <ul class="nav navbar-nav" role="menubar">
          <!--unless submenu-->
          <li class="active nav-home first-li ">
            <a href="/" role="menuitem">Home</a>
          </li>
          <li class="nav-dot nav-home">
            <img src="http://assets-production-webvanta-com.s3-us-west-2.amazonaws.com/000000/51/21/original/images/dot.png" alt="" role="presentation">
          </li>
          <!--if submenu-->
          <li class="dropdown   ">
            <a href="#" data-toggle="dropdown" class="dropdown-toggle" role="button" aria-expanded="false">About<b class="caret"></b></a>
            <ul class="dropdown-menu" role="menu">
              <li class="">
                <a href="/about" role="menuitem">Chair's Welcome</a>
              </li>
              <li class="">
                <a href="/about/history" role="menuitem">History</a>
              </li>
              <li class="">
                <a href="/about/campbell-hall" role="menuitem">Campbell Hall</a>
              </li>
              <li class="">
                <a href="/about/faqs" role="menuitem">FAQs</a>
              </li>
              <li class="">
                <a href="/about/jobs-and-fellowships" role="menuitem">Jobs &amp; Fellowships</a>
              </li>
              <li class="">
                <a href="/about/integrity-statement" role="menuitem">Integrity Statement</a>
              </li>
              <li class="">
                <a href="/about/contact" role="menuitem">Contact</a>
              </li>
            </ul>
          </li>
          <li class="nav-dot">
            <img src="http://assets-production-webvanta-com.s3-us-west-2.amazonaws.com/000000/51/21/original/images/dot.png" alt="" role="presentation">
          </li>
          <!--if submenu-->
          <li class="dropdown   ">
            <a href="#" data-toggle="dropdown" class="dropdown-toggle" role="button" aria-expanded="false">People<b class="caret"></b></a>
            <ul class="dropdown-menu" role="menu">
              <li class="hidden-xs  dropdown-submenu">
                <a href="/people/faculty" role="menuitem">Faculty<b class="caret"></b></a>
              </li>
              <!-- if submenu. repeats previous code but this will show ONLY on MOBILE to expose third tier navigation -->
              <li class="visible-xs  dropdown-submenu">
                <a href="#" class="trigger">Faculty<b class="caret"></b></a>
                <ul class="dropdown-menu sub-menu" role="menu">
                  <li class=" "><a href="/people/faculty/current" role="menuitem">Current</a>
                  </li>
                  <li class=" "><a href="/people/faculty/emeriti" role="menuitem">Emeriti</a>
                  </li>
                </ul>
              </li>
              <li class="">
                <a href="/people/researchers" role="menuitem">Researchers</a>
              </li>
              <li class="">
                <a href="/people/postdocs" role="menuitem">Postdocs</a>
              </li>
              <li class="">
                <a href="/people/visiting-scholars" role="menuitem">Visiting Scholars</a>
              </li>
              <li class="hidden-xs  dropdown-submenu">
                <a href="/people/graduate-students" role="menuitem">Graduate Students<b class="caret"></b></a>
              </li>
              <!-- if submenu. repeats previous code but this will show ONLY on MOBILE to expose third tier navigation -->
              <li class="visible-xs  dropdown-submenu">
                <a href="#" class="trigger">Graduate Students<b class="caret"></b></a>
                <ul class="dropdown-menu sub-menu" role="menu">
                  <li class=""><a href="/people/graduate-students/current" role="menuitem">Current</a>
                  </li>
                  <li class=""><a href="/people/graduate-students/alumni" role="menuitem">Alumni</a>
                  </li>
                </ul>
              </li>
              <li class="">
                <a href="/people/staff" role="menuitem">Staff</a>
              </li>
            </ul>
          </li>
          <li class="nav-dot">
            <img src="http://assets-production-webvanta-com.s3-us-west-2.amazonaws.com/000000/51/21/original/images/dot.png" alt="" role="presentation">
          </li>
          <!--if submenu-->
          <li class="dropdown   ">
            <a href="#" data-toggle="dropdown" class="dropdown-toggle" role="button" aria-expanded="false">News &amp; Events<b class="caret"></b></a>
            <ul class="dropdown-menu" role="menu">
              <li class="">
                <a href="/news" role="menuitem">Department News</a>
              </li>
              <li class="">
                <a href="/news/events" role="menuitem">Department Events</a>
              </li>
              <li class="">
                <a href="http://events.berkeley.edu/index.php/calendar/sn/astro" role="menuitem" class="external" target="_blank">Campus Calendar</a>
              </li>
              <li class="">
                <a href="/news/newsletters" role="menuitem">Newsletters</a>
              </li>
            </ul>
          </li>
          <li class="nav-dot">
            <img src="http://assets-production-webvanta-com.s3-us-west-2.amazonaws.com/000000/51/21/original/images/dot.png" alt="" role="presentation">
          </li>
          <!--if submenu-->
          <li class="dropdown   ">
            <a href="#" data-toggle="dropdown" class="dropdown-toggle" role="button" aria-expanded="false">Academic Programs<b class="caret"></b></a>
            <ul class="dropdown-menu" role="menu">
              <li class="hidden-xs  dropdown-submenu">
                <a href="/programs/undergraduate-program" role="menuitem">Undergraduate<b class="caret"></b></a>
              </li>
              <!-- if submenu. repeats previous code but this will show ONLY on MOBILE to expose third tier navigation -->
              <li class="visible-xs  dropdown-submenu">
                <a href="#" class="trigger">Undergraduate<b class="caret"></b></a>
                <ul class="dropdown-menu sub-menu" role="menu">
                  <li class=""><a href="/programs/undergraduate-program" role="menuitem">Undergraduate Overview</a>
                  </li>
                  <li class=""><a href="/programs/undergraduate-program/astrophysics-major" role="menuitem">Requirements of the Astrophysics Major</a>
                  </li>
                  <li class=""><a href="/programs/undergraduate-program/astrophysics-declaration" role="menuitem">Declaring the Major</a>
                  </li>
                  <li class=""><a href="http://admissions.berkeley.edu" role="menuitem" class="external" target="_blank">How to Apply</a>
                  </li>
                  <li class=""><a href="/programs/undergraduate-program/undergraduate-resources" role="menuitem">Undergraduate Resources</a>
                  </li>
                  <li class=""><a href="/programs/undergraduate-program/undergraduate-student-learning-initiative" role="menuitem">Undergraduate Student Learning Initiative</a>
                  </li>
                  <li class=""><a href="/programs/undergraduate-program/policy-on-academic-misconduct" role="menuitem">Policy on Academic Misconduct</a>
                  </li>
                </ul>
              </li>
              <li class="hidden-xs  dropdown-submenu">
                <a href="/programs/graduate-program" role="menuitem">Graduate<b class="caret"></b></a>
              </li>
              <!-- if submenu. repeats previous code but this will show ONLY on MOBILE to expose third tier navigation -->
              <li class="visible-xs  dropdown-submenu">
                <a href="#" class="trigger">Graduate<b class="caret"></b></a>
                <ul class="dropdown-menu sub-menu" role="menu">
                  <li class=""><a href="/programs/graduate-program" role="menuitem">Graduate Overview</a>
                  </li>
                  <li class=""><a href="/programs/graduate-program/graduate-requirements" role="menuitem">Degree Requirements</a>
                  </li>
                  <li class=""><a href="/programs/graduate-program/graduate-apply" role="menuitem">How to Apply</a>
                  </li>
                  <li class=""><a href="/programs/graduate-program/graduate-resources" role="menuitem">Graduate Resources</a>
                  </li>
                  <li class=""><a href="/programs/graduate-program/teaching-opportunities" role="menuitem">Teaching Opportunities</a>
                  </li>
                  <li class=""><a href="/programs/graduate-program/student-services" role="menuitem">Student Services</a>
                  </li>
                </ul>
              </li>
              <li class="hidden-xs  dropdown-submenu">
                <a href="/courses" role="menuitem">Courses<b class="caret"></b></a>
              </li>
              <!-- if submenu. repeats previous code but this will show ONLY on MOBILE to expose third tier navigation -->
              <li class="visible-xs  dropdown-submenu">
                <a href="#" class="trigger">Courses<b class="caret"></b></a>
                <ul class="dropdown-menu sub-menu" role="menu">
                  <li class="
                                                          
                                                          active 3">
                    <a href="/courses/undergraduate/2015/SU" role="menuitem">
                                                            
                                                            Summer
                                                            
                                                            2015
                                                            • Undergraduate
                                                          </a>
                  </li>
                  <li class="
                                                          
                                                          ">
                    <a href="/courses/undergraduate/2015/SP" role="menuitem">
                                                            Spring
                                                            
                                                            
                                                            2015
                                                            • Undergraduate
                                                          </a>
                  </li>
                  <li class="
                                                          
                                                          active 3">
                    <a href="/courses/graduate/2015/SU" role="menuitem">
                                                            
                                                            Summer
                                                            
                                                            2015
                                                            • Graduate
                                                          </a>
                  </li>
                  <li class="
                                                          
                                                          ">
                    <a href="/courses/graduate/2015/SP" role="menuitem">
                                                            Spring
                                                            
                                                            
                                                            2015
                                                            • Graduate
                                                          </a>
                  </li>
                </ul>
              </li>
              <li class="">
                <a href="/programs/financial-aid" role="menuitem">Financial Aid</a>
              </li>
              <li class="">
                <a href="/programs/student-awards" role="menuitem">Student Prizes and Awards</a>
              </li>
            </ul>
          </li>
          <li class="nav-dot">
            <img src="http://assets-production-webvanta-com.s3-us-west-2.amazonaws.com/000000/51/21/original/images/dot.png" alt="" role="presentation">
          </li>
          <!--if submenu-->
          <li class="dropdown   ">
            <a href="#" data-toggle="dropdown" class="dropdown-toggle" role="button" aria-expanded="false">Prospective Students<b class="caret"></b></a>
            <ul class="dropdown-menu" role="menu">
              <li class="">
                <a href="/prospective-students" role="menuitem">Why Berkeley Astronomy</a>
              </li>
              <li class="">
                <a href="/prospective-students/tuition" role="menuitem">Tuition</a>
              </li>
              <li class="">
                <a href="/prospective-students/unex-and-summer-sessions" role="menuitem">UNEX and Summer Sessions</a>
              </li>
              <li class="">
                <a href="/prospective-students/about-berkeley" role="menuitem">About Berkeley</a>
              </li>
              <li class="">
                <a href="/prospective-students/diversity-statement" role="menuitem">Statement on Diversity</a>
              </li>
            </ul>
          </li>
          <li class="nav-dot">
            <img src="http://assets-production-webvanta-com.s3-us-west-2.amazonaws.com/000000/51/21/original/images/dot.png" alt="" role="presentation">
          </li>
          <!--if submenu-->
          <li class="dropdown   ">
            <a href="#" data-toggle="dropdown" class="dropdown-toggle" role="button" aria-expanded="false">Research &amp; Facilities<b class="caret"></b></a>
            <ul class="dropdown-menu" role="menu">
              <li class="">
                <a href="/research-facilities" role="menuitem">Facilities</a>
              </li>
              <li class="">
                <a href="/research-facilities/organized-research-units" role="menuitem">Organized Research Units</a>
              </li>
              <li class="">
                <a href="/research-facilities/research-opportunities" role="menuitem">Research Opportunities</a>
              </li>
              <li class="">
                <a href="/research-facilities/projects" role="menuitem">Projects</a>
              </li>
              <li class="">
                <a href="/research-facilities/labs" role="menuitem">Labs</a>
              </li>
              <li class="">
                <a href="/research-facilities/libraries" role="menuitem">Libraries</a>
              </li>
            </ul>
          </li>
          <li class="nav-dot">
            <img src="http://assets-production-webvanta-com.s3-us-west-2.amazonaws.com/000000/51/21/original/images/dot.png" alt="" role="presentation">
          </li>
          <!--if submenu-->
          <li class="dropdown   ">
            <a href="#" data-toggle="dropdown" class="dropdown-toggle" role="button" aria-expanded="false">Department Resources<b class="caret"></b></a>
            <ul class="dropdown-menu" role="menu">
              <li class="">
                <a href="/department-resources" role="menuitem">Forms and Documents</a>
              </li>
              <li class="">
                <a href="/department-resources/astronomy-computing-services" role="menuitem">Computing at Berkeley Astronomy</a>
              </li>
              <li class="">
                <a href="/department-resources/campus-services" role="menuitem">Campus Shared Services</a>
              </li>
              <li class="">
                <a href="/department-resources/access-and-building" role="menuitem">Access &amp; Building</a>
              </li>
              <li class="">
                <a href="/department-resources/hosting-visitors" role="menuitem">Hosting Speakers &amp; Visitors</a>
              </li>
              <li class="">
                <a href="/department-resources/building-procedures" role="menuitem">Building Procedures</a>
              </li>
              <li class="">
                <a href="/department-resources/campus-resources" role="menuitem">Campus Resources</a>
              </li>
            </ul>
          </li>
          <li class="nav-dot">
            <img src="http://assets-production-webvanta-com.s3-us-west-2.amazonaws.com/000000/51/21/original/images/dot.png" alt="" role="presentation">
          </li>
          <!--if submenu-->
          <li class="dropdown   last-li">
            <a href="#" data-toggle="dropdown" class="dropdown-toggle" role="button" aria-expanded="false">Friends &amp; Fans<b class="caret"></b></a>
            <ul class="dropdown-menu" role="menu">
              <li class="">
                <a href="/astronomy-fans" role="menuitem">Outreach</a>
              </li>
              <li class="">
                <a href="/astronomy-fans/make-a-gift" role="menuitem">Make A Gift</a>
              </li>
              <li class="">
                <a href="/astronomy-fans/ask-an-astronomer" role="menuitem">Ask an Astronomer</a>
              </li>
              <li class="">
                <a href="/astronomy-fans/local-resources" role="menuitem">Local Resources</a>
              </li>
              <li class="">
                <a href="/astronomy-fans/merchandise" role="menuitem">Department Merchandise</a>
              </li>
            </ul>
          </li>
        </ul>
        <form action="/search" class="search_form visible-xs navbar-form navbar-right" method="post" role="search">
          <div class="input-group">
            <input class="form-control input-sm search_text" name="search_text" type="text" placeholder="">
            <span class="input-group-btn">
              <button type="submit" class="btn btn-color btn-sm"><span class="glyphicon glyphicon-search"></span><span class="sr-only">Search</span>
            </button>
            </span>
          </div>
        </form>
      </div>
    </div>
  </div>
</div>

I have yet to find a work around. Any ideas?

like image 460
Jacob Hyde Avatar asked Apr 21 '15 19:04

Jacob Hyde


1 Answers

If I understand correct this issue comes up whenever the landscape tabs are open. You will be unable to either open/or close the mobile menu.

I managed to fix it with a workaround:

  1. Make an absolute positioned div(with id #ios_menu_fix in this case) about the size of the toggle button.
  2. In css align it where the toggle button would be in the fixed nav menu. Make sure it has z-index set and also -webkit-transform: translate3d(0,0,0); to fix ios z-index issue when scrolling up.
  3. Every time page is scrolled set the top to page scrolled height like so:

    $(window).on('scroll',function() {
    $("#ios_menu_fix").css("top", $(document).scrollTop()+"px");
    }); 
    
  4. Open/close the menu when #ios_menu_fix is clicked

    $(".nav-collapse").collapse('hide');
    $(".nav-collapse").collapse('show');
    

You can check if the menu is open like so:

    var toggle = $(".nav-collapse").is(":visible");
    if (toggle) {
        $(".nav-collapse").collapse('hide');
    }
    else {
        $(".nav-collapse").collapse('show');
    }

Its an ugly solution but the only one I currently find working that doesn't break other mobile browsers and layouts.

These code examples use JQuery.

like image 172
Ectizoi Avatar answered Jan 05 '23 02:01

Ectizoi