PDA

View Full Version : [FIXED] Combo auto-reset while typing with query and forceSelection



Lukappa
3 Oct 2014, 12:31 AM
Extjs: ext-5.0.2.1411 (nightly)

I found an issue with combobox using (remote and local) query/store and forceSelection = true;

When you try to type inside to retrieve remote data, the store loads correctly and items list as well but the value inside the inputField will be blank (like a reset) even if you set autoSelect = false.


This is a problem because until you don't select any item from list, the query should remain there to let user change it.

Lukappa
3 Oct 2014, 2:21 AM
I've found the problem in the getValue method.

Line #1823 of form/field/ComboBox.js (getValue)


// If the raw input value gets out of sync in a multiple ComboBox, then we have to give up.
// Multiple is not designed for typing *and* displaying the comma separated result of selection.
// Same in the case of forceSelection.
if (me.multiSelect || me.forceSelection) {
me.setRawValue('');
value = me.value = undefined;
} else {
value = me.value = rawValue;
}


My solution:


// If the raw input value gets out of sync in a multiple ComboBox, then we have to give up.
// Multiple is not designed for typing *and* displaying the comma separated result of selection.
// Same in the case of forceSelection.
if (me.multiSelect || (me.forceSelection && me.queryMode == 'local')) {
me.setRawValue('');
value = me.value = undefined;
} else {
value = me.value = rawValue;
}


In this way we reset the raw value only if queryMode is local and value doesn't match with any record.

Gary Schlosberg
3 Oct 2014, 5:24 AM
Thanks for the report. I haven't been able to reproduce this issue. Can you please post a test case which shows the problem?
https://fiddle.sencha.com/#home

Lukappa
3 Oct 2014, 5:32 AM
Hello Gary,
here you can test it.. https://fiddle.sencha.com/#fiddle/ba1

As I can see the problem is even with local query
So the solution would be to delete the check on forceSelection




if (me.multiSelect) {
me.setRawValue('');
value = me.value = undefined;
}
else {
value = me.value = rawValue; ...

Gary Schlosberg
6 Oct 2014, 2:22 PM
Thanks, I see it now. I think this issue was reported here:
http://www.sencha.com/forum/showthread.php?291421

timothy_browne
17 Oct 2014, 9:21 AM
Thanks, I see it now. I think this issue was reported here:
http://www.sencha.com/forum/showthread.php?291421


I'm afraid you're wrong. The error you linked to is a separate issue primarily stemming from binding. You remove the binding from their example, and the issue goes away. I would presume that issue is from the fact that while forceSelection is in effect, it returns null on getValue until a record is selected. Something along the lines of the bind watches the change event occurs: the bind picks up that the raw value has change, does a getValue, receives null, sends that to the bound value. Then because the bound value has changed, it checks to make sure that fields bound to that value are changed to match. Because it received null, the combobox is set to null as well, which erases the rawValue.



The error that Lukappa, and I, have stems from the line Lukappa already quoted, which is only found on the nightly builds, in ComboBox.getValue:



// If the raw input value gets out of sync in a multiple ComboBox, then we have to give up.
// Multiple is not designed for typing *and* displaying the comma separated result of selection.
// Same in the case of forceSelection.
if (me.multiSelect || me.forceSelection) {
me.setRawValue('');
value = me.value = undefined;
} else {
value = me.value = rawValue;
}


The effect that code has is to reset the rawValue every time getValue is called, which happens every time doRawQuery is called.

This very much is a bug, in that the primary use case for forceSelection === true && editable === true is to allow a user to search through a very long combo box, but force the user to choose one of the options it offers.

Gary Schlosberg
17 Oct 2014, 12:41 PM
Thanks for the pointing that out. I have opened a bug in our bug tracker.