Skip to content

Incorrect ion-content height after first keyboard show in a view #6715

@vizeke

Description

@vizeke

Type: bug

Ionic Version: 1.3.*

Platform: android

Description
After navigate to a view, when you click on a text input for the first time the screen gets blank after the keyboard appears.

Steps to reproduce the probem

  1. Navigate to a screen
  2. Click on a input to open the keyboard for the first time (the subsequent input clicks works just fine)

Here is a vídeo showing the problem:
https://drive.google.com/open?id=0B7I6TA0ByZuvZ01PSlRJOXZucjA

A css height is applied to the ion-content tag to resize it, but the value is wrong.

Fix Sugestion

Tracking down the issue in the js/views/scrollViewNative.js file, I found that since version 1.2.2 there's a __originalContainerHeight variable to help adjust the screensize when the keyboard shows up. The problem is that the value of __originalContainerHeight is set only after the keyboard is already open making it's value smaller than it should be.

In my case the solution was setting the __originalContainerHeight in the initialize method of the ionic.views.ScrollNative, inside the ionic.requestAnimationFrame function, this way the screen is ready and the value from getBoundingClientRect() is correct.

ionic.requestAnimationFrame(function() {
      self.__originalContainerHeight = self.el.getBoundingClientRect().height; //add line

      self.el.scrollTop = options.startY || 0;
      self.el.scrollLeft = options.startX || 0;

      self.__scrollTop = self.el.scrollTop;
      self.__scrollLeft = self.el.scrollLeft;
});

obs: This variable is also set in the resetScrollView method of ScrollNative, after the keyboard is hiden, that's why it works after the first time.

Ionic Info:
Cordova CLI: 6.1.1
Gulp version: Requiring external module babel-register
Gulp local: CLI version 3.9.1
Ionic CLI Version: 1.7.15
Ionic App Lib Version: 0.7.2
OS: Windows 8.1
Node Version: v5.10.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions