PDA

View Full Version : [OPEN] 1.1.0: Bug with "return false" from Ext.form.ToggleField#beforechange listener



AlexKorn
12 May 2011, 10:22 PM
Sencha Touch version tested:

1.1.0

only default ext-all.css




Platform tested against:

Latest desktop Chrome (should be platform-independent)


Description:

Returning


Test Case:

See this URL : http://jsfiddle.net/WJ5pp/
There's a JS error that happens on page render, but this doesn't appear to have anything to do with the bug at hand (and this page gives similar results to my app, which does not have any JS errors).


Steps to reproduce the problem:

Run the above fiddle.
Try to check the field.


The result that was expected:

The toggle field doesn't change at all.


The result that occurs instead:

The class for the toggle field changes (although the value doesn't), making the toggle turn green when it shouldn't.


Possible fix (change in bold):


Ext.override(Ext.form.Toggle, {
setValue: function(value) {
Ext.form.Toggle.superclass.setValue.call(this, value, this.animationDuration);

// Because value might change in the parent's setValue(), refresh it
value = this.getValue();

var fieldEl = this.fieldEl;

if (this.constrain(value) === this.minValue) {
fieldEl.addCls(this.minValueCls);
fieldEl.removeCls(this.maxValueCls);
}
else {
fieldEl.addCls(this.maxValueCls);
fieldEl.removeCls(this.minValueCls);
}
}
});

robertmiles3
15 Jun 2011, 4:08 AM
Thanks for this fix. I noticed this yesterday after returning "false" from a validation on beforechange. Was getting frustrated.