PDA

View Full Version : Combo forceSelection not clearing out invaild text on blur



jaycmadison
14 Jan 2014, 2:08 PM
If I blur off my combobox right as my store beings to load the text value I type in remains in the field even if I have "forceSelection = true" set. I could type in junk data "adfadfasf" and this can get processed through using getValue() on the combobox. That junk data is obviously not an option so it should not be returned. I noticed that this junk data remains as the raw value after I have moved off the field.

To replicate you must move off the field right as the store (remote store) begins to load and before the data comes back.

We are currently on version 4.1.3.

I do have an override that appears to work as I expect. I simply set the raw value if no record was found and forceSelection = true.



Ext.override(Ext.form.ComboBox, {
assertValue: function () {
var me = this,
value = me.getRawValue(),
rec, currentValue;

if (me.forceSelection) {
if (me.multiSelect) {
// For multiselect, check that the current displayed value matches the current
// selection, if it does not then revert to the most recent selection.
if (value !== me.getDisplayValue()) {
me.setValue(me.lastSelection);
}
} else {
// For single-select, match the displayed value to a record and select it,
// if it does not match a record then revert to the most recent selection.
rec = me.findRecordByDisplay(value);
if (rec) {
currentValue = me.value;
// Prevent an issue where we have duplicate display values with
// different underlying values.
if (!me.findRecordByValue(currentValue)) {
me.select(rec, true);
}
} else {
me.setValue(me.lastSelection);
me.setRawValue(me.lastSelection);
}
}
}
me.collapse();
}
});

Gary Schlosberg
14 Jan 2014, 2:46 PM
Thanks for the report. Do you know if this is occurring with ExtJS 4.2.1? Can you post a test case which reproduces it?
https://fiddle.sencha.com/#home