You found a bug! We've classified it as TOUCH-4249 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Sencha User hectorgomis's Avatar
    Join Date
    Feb 2013
    Location
    Spain
    Posts
    42
    Vote Rating
    0
    hectorgomis is on a distinguished road

      0  

    Default InputText is hided after keyboard opened on Android. Working OK on 2.1.0 only

    InputText is hided after keyboard opened on Android. Working OK on 2.1.0 only


    We are developing an App on ST2.1.1 with Phonegap 2.5, but we found a problem using this ST version, trying to write down in a form text field. After I clicked in this input, Android keyboard is displayed hidding the field. I was very supprised, because changing ST version to 2.1.0 in app.html, everything was working perfectly. I tested the issue on ST2.2.0beta, and it's not working too.
    I have tested with Android tablets and mobiles, versions 4.0.4, 4.1.1, and building the project with every value of android:windowSoftInputMode. Now I'm using adjustResize value.
    I have tested the same project on iOS, and everything was ok, with every version of ST.


    I attached some media to clarify the bug.
    - Video 1: Everything is working ok with ST2.1.0 on Android Tablet
    (https://www.dropbox.com/s/yl1vh2q6tz...rkingFocus.mp4)
    - Video 2: Bug on ST2.1.1 on Android Tablet
    (https://www.dropbox.com/s/63ijrv6bze...rkingFocus.mp4)
    - Architect project, where you can change ST version to try the issue
    (https://www.dropbox.com/s/0p8e7m3t7q...tArchitect.rar)

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,206
    Vote Rating
    856
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Thanks for the report! I have opened a bug in our bug tracker.

  3. #3
    Sencha User hectorgomis's Avatar
    Join Date
    Feb 2013
    Location
    Spain
    Posts
    42
    Vote Rating
    0
    hectorgomis is on a distinguished road

      0  

    Default


    How can I know when the bug will be solved?

  4. #4
    Sencha User hectorgomis's Avatar
    Join Date
    Feb 2013
    Location
    Spain
    Posts
    42
    Vote Rating
    0
    hectorgomis is on a distinguished road

      0  

    Default


    Is this bug solved in ST2.2.0?

  5. #5
    Sencha User
    Join Date
    Apr 2013
    Posts
    36
    Vote Rating
    0
    PabloPerezAdsuar is on a distinguished road

      0  

    Default


    Hi! I have a good solution!! When I press a button, I use scrollTo method.

    Paste link with a example:
    http://stackoverflow.com/questions/15596111/sencha-touch-2-1-form-panel-keyboard-hides-active-textfield-on-android

  6. #6
    Sencha User hectorgomis's Avatar
    Join Date
    Feb 2013
    Location
    Spain
    Posts
    42
    Vote Rating
    0
    hectorgomis is on a distinguished road

      0  

    Default


    It is not working properly in all cases.... Anybody knows what ST version will fix this bug??

    Thanks

  7. #7
    Sencha User
    Join Date
    Sep 2013
    Posts
    10
    Vote Rating
    0
    AIDevMob is on a distinguished road

      0  

    Default


    Has there been any progress on this? We are using Touch 2.3.0 and Cordova 3.2.0 and this is a real problem for us. Thanks.

  8. #8
    Touch Premium Member JL's Avatar
    Join Date
    May 2007
    Posts
    89
    Vote Rating
    0
    JL is on a distinguished road

      0  

    Default


    I've managed to come up with a work around with a combination of modifying the SoftKeyboard plugin (which I'm using for showing the keyboard programmatically) and overriding the Ext.field.Text class.

    First I added a method to the SoftKeyboard plugin called scrollView:

    Code:
    SoftKeyboard.prototype.scrollView = function(x, y) {
        return cordova.exec(null, null, "SoftKeyboard", "scrollView", [{x: x, y: y}]);
    };
    Code:
    View activityRootView;
    
    public SoftKeyboard() {
    }
    
    public void scrollView(int x, int y) {
    	if (activityRootView == null) {
    		activityRootView = ((ViewGroup) this.cordova.getActivity().findViewById(android.R.id.content)).getChildAt(0);    		
    		activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
    						@Override
    						public void onGlobalLayout() 
    						{
    							Rect r = new Rect();
    							activityRootView.getWindowVisibleDisplayFrame(r);
    							int heightDiff = activityRootView.getRootView().getHeight() - (r.bottom - r.top);
    							// If less than 100 pixels, its probably that the user hid the keyboard with the hardware button
    								if (heightDiff < 100) 
    								{
    									activityRootView.scrollTo(0, 0);
    								}                
    						}
    				});
    	}
    		
    	activityRootView.scrollTo(x, y);    	
    }
    I also added a call to fix the panning / scrolling when hiding the SoftKeyboard:

    Code:
    SoftKeyboard.prototype.hide = function(win, fail) {
    	Ext.defer(function() {
    		cordova.plugins.SoftKeyboard.scrollView(0, 0);
    	}, 150);
    						
    	return cordova.exec(
    			function (args) { if(win !== undefined) { win(args); } },
    			function (args) { if(fail !== undefined) { fail(args); } },
    			"SoftKeyboard", "hide", []);
    };
    Now as far as overriding Ext.field.Text, I added these listeners:

    Code:
    if (!(this instanceof Ext.field.Select) && !Ext.os.is.Desktop && Ext.os.is.Android && cordova.plugins.SoftKeyboard) {
    	this.onAfter("focus", this.focused, this);
    	this.element.onAfter("tap", this.tapped, this);
    }
    And these methods:

    Code:
    // On Android, show the keyboard when programatically focusing a field
    focus: function() {
    	this.callParent(arguments);
    	if (!(this instanceof Ext.field.Select) && !Ext.os.is.Desktop && Ext.os.is.Android && cordova.plugins.SoftKeyboard) {
    		Ext.defer(function() {
    			cordova.plugins.SoftKeyboard.show();
    		}, 50);
    	}
    },
    
    focused: function() {
    	// re-adjust the body margin so the field is in view and not hidden from the keyboard
    	// an apparent Android bug, android:windowSoftInputMode="stateUnspecified|adjustPan" doesn't work as expected
    	// 100 is an arbitrary number of where the "top" of the keyboard is
    	Ext.defer(function() {
    		var maxOffset = window.innerHeight - 100,
    		margin = (this.element.getY() - this.element.getHeight()) - 100;
    
    		if (margin >= 0) {
    			if (margin > maxOffset) {
    				margin = maxOffset;
    			}
    			cordova.plugins.SoftKeyboard.scrollView(0, margin);
    		}
    	}, 150, this);
    },
    
    // of user hides the keyboard with the hardware button, the field is still focused so tapping the field doesn't bring the keyboard back up in some cases
    tapped: function() {
    	this.focused();
    }
    Also, in the AndroidManifest.xml, the activity tag's softInputMode attribute needs to be set to pan as opposed to resize (notice it appears to be in the wrong location by default, it's on the manifest tag and should be on the activity tag according to the API):

    Code:
    android:windowSoftInputMode="stateUnspecified|adjustPan"
    A bit extensive / complicated, but I tried without success taking a similar approach purely in JS (scrolling or repositioning the body or Viewport etc…). Every time I repositioned something the field would lose focus.

    Hope this helps until Cordova or Sencha can come up with some sort of solution, it appears to be an android web view bug.

  9. #9
    Sencha User
    Join Date
    Oct 2012
    Posts
    71
    Vote Rating
    2
    Tioecomp is on a distinguished road

      0  

    Default


    I thought that it was a new bug from this last release, its a shame that a bug like that is happening since 2.2v.

  10. #10
    Sencha User
    Join Date
    Jan 2014
    Posts
    8
    Vote Rating
    0
    Allen Wu is on a distinguished road

      0  

    Default


    I am developing a mobile-adapted web page with Sencha Touch and same issue happens to me... I've tried PabloPerezAdsuar's solutions in #5, and the web page scrolled correctly in my PC browser, however it couldn't scroll in my Android device.