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

Duplicate of #818

rvanbaalen avatar Mar 27 '14 23:03 rvanbaalen

Thanks. We're working on these keyboard bugs for beta2.

ajoslin avatar Mar 28 '14 12:03 ajoslin

Do you have any lead on what might cause this? By the time you plan to release beta2, my app is already out in the wild ;-)

rvanbaalen avatar Mar 28 '14 12:03 rvanbaalen

Here is a working demonstration of this problem:

I just tested this via the "Getting Started" process using "Ionic, v1.0.0-beta.1".

My Steps:

  • npm install -g cordova ionic
  • ionic start statusBarTest sidemenu
  • ionic platform add ios

I then edited app.js to start with a simple form. :

<ion-view title="Form Test">
  <ion-nav-buttons side="left">
    <button menu-toggle="left" class="button button-icon icon ion-navicon"></button>
  </ion-nav-buttons>
  <ion-content class="has-header">

    <div class="list">
      <label class="item item-input">
        <input type="text" placeholder="First Name">
      </label>
      <label class="item item-input">
        <input type="text" placeholder="Middle Name">
      </label>
      <label class="item item-input">
        <input type="text" placeholder="Last Name">
      </label>
      <label class="item item-input">
        <input type="text" placeholder="Address 1">
      </label>
      <label class="item item-input">
        <input type="text" placeholder="Address 2">
      </label>
      <label class="item item-input">
        <input type="text" placeholder="City">
      </label>
      <label class="item item-input">
        <input type="text" placeholder="State">
      </label>
      <label class="item item-input">
        <input type="text" placeholder="Zip Code">
      </label>
    </div>

  </ion-content>
</ion-view>

Then:

  • ionic build ios
  • ionic emulate ios

Here is the result:

status bar problem

As you can see, the keyboard pushes the form up into the status bar.

calendee avatar Apr 02 '14 21:04 calendee

Hey Justin, I believe the issue is that has position: fixed. Try changing the body css to position:static. Sorry I haven't pushed the fix yet, we're still testing out the keyboard stuff across devices right now.

Give that a shot and let me know if it helps.

On Wed, Apr 2, 2014 at 4:34 PM, Justin Noel [email protected]:

Here is a working demonstration of this problem:

I just tested this via the "Getting Started" process using "Ionic, v1.0.0-beta.1".

My Steps:

  • npm install -g cordova ionic
  • ionic start statusBarTest sidemenu
  • ionic platform add ios

I then edited app.js to start with a simple form. :

<div class="list">
  <label class="item item-input">
    <input type="text" placeholder="First Name">
  </label>
  <label class="item item-input">
    <input type="text" placeholder="Middle Name">
  </label>
  <label class="item item-input">
    <input type="text" placeholder="Last Name">
  </label>
  <label class="item item-input">
    <input type="text" placeholder="Address 1">
  </label>
  <label class="item item-input">
    <input type="text" placeholder="Address 2">
  </label>
  <label class="item item-input">
    <input type="text" placeholder="City">
  </label>
  <label class="item item-input">
    <input type="text" placeholder="State">
  </label>
  <label class="item item-input">
    <input type="text" placeholder="Zip Code">
  </label>
</div>

Then:

  • ionic build ios
  • ionic emulate ios

Here is the result:

[image: status bar problem]https://cloud.githubusercontent.com/assets/57374/2597008/fb174690-baad-11e3-80aa-c88985210bcb.gif

As you can see, the keyboard pushes the form up into the status bar.

Reply to this email directly or view it on GitHubhttps://github.com/driftyco/ionic/issues/932#issuecomment-39386769 .

tlancina avatar Apr 02 '14 22:04 tlancina

Unfortunately, that didn't help. In the sample project, I added this to the "style.css":

body, .ionic-body {
    position: static;
}

That didn't work even though "style.css" is included after the Ionic CSS file. I also confirmed in Safari debug that the position: static had been applied to the body.

So, I then tried just body with no luck.

body {
    position: static;
}

Next, I just updated the "ionic.css" file. This still did not work.

I also thought you might have meant to make the header static; so I gave it a try. No luck with that either.

calendee avatar Apr 02 '14 22:04 calendee

Ah didn't see it is iOS 7.1 only. I don't have access to a Mac right now so I'll take a look first thing tomorrow. Thanks for your help looking into this.

tlancina avatar Apr 02 '14 23:04 tlancina

Thanks for the working demo Justin :+1:

rvanbaalen avatar Apr 03 '14 02:04 rvanbaalen

Depending on your setup, setting .body to position:static wont fix anything, as .pane and .view also have position absolute.

In custom mobile web apps i have built, the header needs to be outside of any of these heavily position elements and the header itself set to position:fixed to stay there when the keyboard is up. Android has an option called adjust-resize which squishes the view to fit above the keyboard. iOS on the other hand, just pans the view to center the input on the screen.

Cordova also has an preference called "KeyboardShrinksView" which is defaulted to false. I havent looked at this yet but it looks like a solution for iOS to what Android already does with adjust-resize

Creating a harmony between both of these differences is one HELL of a job

ashconnell avatar Apr 14 '14 23:04 ashconnell

We're actively working on keyboard fixes now to stop all of these problems.

ajoslin avatar Apr 15 '14 02:04 ajoslin

This bug is unfortunately not fixed in nightly 1717.

CoenWarmer avatar Apr 18 '14 12:04 CoenWarmer

One thing that @tlancina noticed is that with the latest tap fixes, if you click the input directly it does not move the header up. So I think we solved part of this issue. However, if you tap the label that wraps an input, then 300ms later it will do the ugly native scroll. The way the default Ionic css works it's hard to tell the difference between the wrapping label and the actual input, so this might be part of the reason it doesn't always work. I've been using this test page to help debug these issues on each device.

Right now I think the reason is because we're not preventing the default on a label click. If we do e.preventDefault() on a label wrapping an input then the keyboard will not automatically popup on the first tap. I'll looking into this more, thanks.

adamdbradley avatar Apr 18 '14 13:04 adamdbradley

@adamdbradley volunteering as another tester for this fix when it gets into the nightlies. thx.

whitneyland avatar Apr 23 '14 14:04 whitneyland

Unfortunately this issue is not yet resolved in 1.0.0 beta2.

CoenWarmer avatar Apr 29 '14 00:04 CoenWarmer

@CoenWarmer We're aware of the issues and still working on it. Also, keep in mind that when reporting any keyboard issues please provide the platform, platform version, and is the issue in the mobile browser, emulator, or in cordova, and if it's cordova, is it full screen or not. Other useful information includes the element you tapped, such as the label or the input, did you have to manually scroll at any time to get to an input, does the meta viewport have height=device-height or not, and if the element is below where the virtual keyboard would eventually show, is it half showing where the keyboard would show, or is it above and no need to scroll. Thanks

adamdbradley avatar Apr 29 '14 01:04 adamdbradley

Encountered on:

  • iOS7.1.1
  • Ionic 1.0.0 beta 2
  • in Cordova
  • in simulator and device
  • not full screen
  • no label used, only input
  • the view can be scrolled after the input field gets focus, if the input field has no focus the view can not be scrolled
  • the view doesn't scroll immediately after it gets focus and the keyboard pops up. When the input field gets focus you can then place your finger on the input field and drag up to move the view out of the webview.

Also happens on Android 4.4 and 4.3, also using 1.0.0 beta2. Exact same circumstances as iOS7.1. So when input field gets focus and keyboard pops up, nothing is wrong, it is when the input gets focus and you then place your finger on the input field and start dragging it up or down that's when you can move all content out of the view. Will make a screencast later.

CoenWarmer avatar Apr 29 '14 06:04 CoenWarmer

Screencast: https://www.dropbox.com/s/2g6b41n3s3vpj0s/2.mov

CoenWarmer avatar Apr 29 '14 07:04 CoenWarmer

After beta2 I have this problem on small screens (like iphone3 or iphone4).

iphone 5 (ok)

iphone5

iphone 4 (problems)

iphone4

zelphir avatar Apr 29 '14 13:04 zelphir

@zelphir Can you please provide a codepen that replicates this issue? Are they both iOS 7.0, or 7.1?

adamdbradley avatar Apr 29 '14 14:04 adamdbradley

@CoenWarmer is your input in a content area by chance? The only way I am able to replicate your issue is by having an input that isn't in a scroll view.

Just to clarify - this is expected behavior if you aren't using a scroll view. If there are inputs below the keyboard, and you are unable to scroll to them using JS, then the browser is forced to shift the content up for them to be visible, which is why you are able to move everything upwards.

tlancina avatar Apr 29 '14 15:04 tlancina