PDA

View Full Version : [FIXED] TextField doesn't pass arguments to parent call



Patlatus
16 Apr 2013, 4:46 AM
REQUIRED INFORMATION




Ext version tested:

Ext 4.1.0, Ext 4.1.1, Ext 4.2.0



Browser versions tested against:

IE8
FF
Chrome



Description:

TextField doesn't pass arguments to parent call



Steps to reproduce the problem:

Override Ext.field.Field to change its behavior
Try to use arguments from onChange function



The result that was expected:

Both arguments, newVal and oldVal, should be passed from TextField.onChange function



The result that occurs instead:

Neither of arguments, neither newVal nor oldVal is not passed from TextField.onChange function to parent call



Test Case:




Ext.onReady(function() {
Ext.define('TreX.overrides.OverrideFieldField', {
override : 'Ext.form.field.Field',

onChange : function( newVal, oldVal ) {
var me = this;
// I want to validate field only if value has been changed
if (newVal !== oldVal) {
me.callParent(arguments);
if (window.console) {
console.log('This never happen, since newVal === oldVal === undefined');
}
}
if (window.console) {
console.log('onChange called; with empty arguments list, check by yourself: ' + newVal + ' ' + oldVal);
}

}
}, function () {
Ext.form.CheckboxGroup.prototype.onChange = Ext.form.field.Field.prototype.onChange;
Ext.form.field.Base.prototype.onChange = Ext.form.field.Field.prototype.onChange;
Ext.form.field.HtmlEditor.prototype.onChange = Ext.form.field.Field.prototype.onChange;
//Ext.ux.form.MultiSelect.prototype.onChange = Ext.form.field.Field.prototype.onChange;
});

Ext.create('Ext.panel.Panel', {
title: 'Panel with VerticalTextItem',
width: 300,
height: 200,
lbar: {
layout: {
align: 'center'
},
items: [{
xtype: 'label',
text: 'Just try to type something in textfield'
}, {
xtype: 'textfield',
text: 'Sample VerticalTextItem'
}]
},
renderTo: Ext.getBody()
});
});







HELPFUL INFORMATION




Screenshot or Video:

Here 43165



See this URL for live test case: http://jsfiddle.net/Patlatus/etg5R/1/




Debugging already done:

yes



Possible fix:
Change this
onChange: function() {
this.callParent();
this.autoSize();
}
to this

onChange: function() {
this.callParent(arguments);
this.autoSize();
}



Additional CSS used:

only default ext-all.css



Operating System:

Win7

evant
16 Apr 2013, 4:55 AM
This doesn't really affect anything unless you're overriding core parts of the framework. But I suppose it can't hurt to relay the arguments to onChange, even if the default Field doesn't use them.