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

Header bar moves up behind statusbar or even completely out of the viewport when form field is focussed

Open rvanbaalen opened this issue 12 years ago • 72 comments

Well.. that about sums it up ^

Screenshot (Ionic beta 1, iPhone 4):

photo-1 photo

rvanbaalen avatar Mar 27 '14 16:03 rvanbaalen

@tlancina My input is not within a content area.

This is the code I'm using:

<ion-view title="Delegates">
  <div class="search-container">
    <div class="search-inner">
      <input ng-model="searchText" placeholder="Search" ng-enter="ScrollTop()">
    </div>
  </div>

  <ion-tabs class="tabs-icon-only tabs-double">
    <ion-tab title="A-Z">
      <ion-content class="slide-under-header has-header has-tabs has-double-tabs" padding="false" delegate-handle="DelegateScroll">
        <!-- stuff -->
      </ion-content>
    </ion-tab>
    <!-- another ion-tab -->
  <ion-tabs>
</ion-view>

I'm not sure I entirely follow what you're saying about this being the expected behavior. Right now it looks like the app is breaking when everything scrolls under the header. Should I instead place the input field within an ion-content?

CoenWarmer avatar Apr 29 '14 16:04 CoenWarmer

Well suppose you have a list of several inputs, reaching to the bottom of your page. If they are not within an area that can be scrolled to using Javascript, how can they be brought into view when the keyboard comes up? The only way is to use the native browser scrolling, which works by shifting the content - all of it, including the header.

When an input or focusable area is within an ionic scroll view, we prevent the default scrolling and use Javascript to bring it into view, leaving the header in place.

I am not an ui-router expert unfortunately, but try placing the ion-content around all of the content on the page and see if that helps.

tlancina avatar Apr 29 '14 16:04 tlancina

I understand now- but doesn't that lead to the undesirable visual effect of the whole nav-bar disappearing including the back button?

More to the point in my use case, if I put the input field within a ion-content, how can I make sure they stay fixed at the top underneath the header bar in a way that transition animations work correctly on iOS and Android?

CoenWarmer avatar Apr 29 '14 16:04 CoenWarmer

Yeah the situation of juggling tabs and maintaining a scrollable area for an input seems pretty tricky, and one that is bound to happen fairly often. @adamdbradley and I are looking into it right now.

Not sure I understand the issue with transitions, if you do something like

<ion-content>
  <div class="search-container">
    <div class="search-inner">
      <input ng-model="searchText" placeholder="Search" ng-enter="ScrollTop()">
    </div>
  </div>
</ion-content>

does it mess up the animations? It's quite possible having multiple content areas will mess other things up, as the assumption is probably that there is only one.

tlancina avatar Apr 29 '14 16:04 tlancina

@tlancina Ah great, I didn't consider using two ion-content elements in one partial. Will see how that works out and report back.

The issue with transition animations that I was referring to occurs on certain Android versions. If you use position: static on an element and you transition away from that view, on Android 4.1 to 4.3 (I believe, not 100% sure, will check) those elements will remain locked once the animation begins. So all elements (ion-content, tabs, header bars, etc) will start moving to the left, but the element that you've given position: static will remain in the same place until the animation completes. This doesn't happen on iOS. This is why I was hesitant to use position static anywhere.

CoenWarmer avatar Apr 29 '14 16:04 CoenWarmer

@tlancina Just tried putting the input element in one ion-content, and having the rest of the content in another, second ion-content. Unfortunately any input entered in the input element will now no longer filter the ng-repeat that's in the other ion-content. Other suggestions?

CoenWarmer avatar Apr 29 '14 17:04 CoenWarmer

@CoenWarmer that's because the ion-content creates a child scope.

Try putting a controller over both contents. If the controller is, then don't just use a primitive for the input.

You're suffering 'the dot' problem of scope inheritance - a primitive in a different child scope is being set on the child scope, not on the parent scope. Do you know what I mean? If you don't, lemme know and I'll find a link / explain it.

ajoslin avatar Apr 29 '14 17:04 ajoslin

Not familiar with it, unfortunately no. Care to share? :)

CoenWarmer avatar Apr 29 '14 17:04 CoenWarmer

https://www.youtube.com/watch?v=DTx23w4z6Kc

ajoslin avatar Apr 29 '14 17:04 ajoslin

Ah, yup, that makes sense! Gonna give it another go :+1:

CoenWarmer avatar Apr 29 '14 17:04 CoenWarmer

hey @adam. How about a footer with an input? Since that's outside the scroll area, it's going to cause the problem too. Any way around that?

calendee avatar Apr 30 '14 02:04 calendee

I also have this problem on iPad (7.1). I saw that ionic adds height=device-height to the viewport after recent changes if it's not set. Because of this property the viewport gets about 200px (height) to large and is completely scrollable. When i remove it it works. I can fix this if somehow if i set .view and .pane to position: fixed and body to position: static, but the main viewport is still to large and shows a scrollbar on the right side if i move the finger up and down.

D3CK3R avatar Apr 30 '14 13:04 D3CK3R

By the way ... this is independent from input focus. The input focus only moves the scroll position so you can see the result.

D3CK3R avatar Apr 30 '14 13:04 D3CK3R

Hey guys, what's the current progress here? I created a custom ionic file and removed the addition 'height=device-height' from it. After this change everything works fine. No CSS fixes needed anymore and focus on input field tap is working correctly. I'm also using the Keyboard plugin on iOS and do the following:

Keyboard.shrinkView(true);
Keyboard.hideFormAccessoryBar(true);

D3CK3R avatar Apr 30 '14 23:04 D3CK3R

Placing the input in a separate ion-content also doesn't stop the behavior of making the entire view including the header bar scrollable underneath the webview when the input gets focus. Same behavior occurs as in my previous screencast: https://www.dropbox.com/s/2g6b41n3s3vpj0s/2.mov

CoenWarmer avatar May 01 '14 22:05 CoenWarmer

@D3CK3R we're working on getting all the different viewport scenarios straightened out :)

@CoenWarmer would you mind giving the Ionic Keyboard Plugin a run? We just made it public and I'm curious to see how it will work on inputs outside of a scroll view.

You can install it by running cordova plugin add https://github.com/driftyco/ionic-plugins-keyboard.git from inside your Cordova project.

tlancina avatar May 02 '14 00:05 tlancina

@tlancina That works! After I added the plugin the content is no longer draggable under the viewport when the input has focus. Awesome!!

Is the plugin ready for production? I'd love to deploy this as soon as possible since this project has just been published to the store.

CoenWarmer avatar May 02 '14 08:05 CoenWarmer

@CoenWarmer you have no idea how happy I was to see your last comment! Great work @tlancina!

adamdbradley avatar May 02 '14 13:05 adamdbradley

@adamdbradley @tlancina highfive

CoenWarmer avatar May 02 '14 13:05 CoenWarmer

Yeah!!!

ajoslin avatar May 02 '14 13:05 ajoslin