-
24 Jan 2012 3:48 PM #1
[PR4] searchfield focuses when I call setWidth()
[PR4] searchfield focuses when I call setWidth()
I have a searchfield that's getting focused on my iPod Touch (not on chrome on my desktop) when I call setWidth() on it. It's annoying because it causes the on-screen keyboard to appear. This started happening when I upgraded to ST2-pr4 from pr3. I was just wondering if anyone else has run into this.
-
24 Jan 2012 5:10 PM #2
Odd. What version of iOS are you running on your iPod? I can't reproduce this with a quick testcase.
Sencha Inc.
Robert Dougan - @rdougan
Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.
-
24 Jan 2012 5:11 PM #3
iOS 5.0.1. I'll try to put together a test case. Maybe it's related to something else going on in my app as well.
-
24 Jan 2012 5:16 PM #4
This is the testcase I used:
Tested on the latest iPod with iOS 5.0.1 with no issues.Code:Ext.setup({ onReady: function() { f = Ext.Viewport.add({ xtype: 'searchfield', label: 'search' }); setTimeout(function() { f.setWidth(100); }, 2000); } });
Let me know if you can create a testcase and I'll take a look.Sencha Inc.
Robert Dougan - @rdougan
Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.
-
24 Jan 2012 6:40 PM #5
Here's a test case to see the behavior I'm talking about:
It doesn't actually have to do with setWidth(). The tap event on the button seems to be going through to the input field, once it changes position due to the button being hidden.Code:Ext.setup({ viewport: { layout: { type: 'hbox', align: 'middle' }, defaults: { flex: 1, height: 40 }, style: 'background-color: grey;' }, onReady: function() { Ext.Viewport.add([ { xtype: 'button', text: 'Back', handler: function(a) { a.hide(); } }, { xtype: 'searchfield', style: 'background-color: white;' }, ]); } });
-
25 Jan 2012 10:11 AM #6
Damn, that's a good catch.
Quick fix:
Code:Ext.define('Ext.overrides.Button', { overrides: 'Ext.Button', doTap: function(me, e) { var handler = me.getHandler(), scope = me.getScope() || me; if (!handler) { return; } if (typeof handler == 'string') { handler = scope[handler]; } //this is done so if you hide the button in the handler, the tap event will not fire on the new element //where the button was. e.preventDefault(); handler.apply(scope, arguments); } });Sencha Inc.
Robert Dougan - @rdougan
Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.
-
25 Jan 2012 12:17 PM #7
Hey,
Thanks for fixing it. That override code doesn't seem to be overriding the tap for me... I put some log messages in the doTap function that aren't getting called.
-
25 Jan 2012 12:33 PM #8
I ended up fixing it by just extending Ext.Button and using the extended class. I couldn't get Ext.overrides to work... strange.
Success! Looks like we've fixed this one. According to our records the fix was applied for
TOUCH-1574
in
2.0.


Reply With Quote