]> git.proxmox.com Git - proxmox-widget-toolkit.git/commitdiff
fix comboBox validation when forceSelection is true
authorTim Marx <t.marx@proxmox.com>
Fri, 25 Oct 2019 11:06:08 +0000 (13:06 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 25 Oct 2019 15:43:23 +0000 (17:43 +0200)
Prevent the comboBox from displaying a validation error although
forceSelection is true. If you change a valid selection by removing
characters manually and click somewhere else, the comboBox restores
the selection with the previous value. The validation logic then
checked the restored value, but couldn't find it in the store,
because the store is still filtered with the erroneous query.

We now clear the local filter before the actual check to prevent
this.

[Thomas]:
This was fixed in the 6.2 based GPL release of ExtJS, and can be seen
as backport.

Signed-off-by: Tim Marx <t.marx@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
form/ComboGrid.js

index c3e778237ca798d2cac9d4f1048ed28ec5c8da5c..6dac5341e937bf3c5fc154af8fa9714c763d4d44 100644 (file)
@@ -310,6 +310,18 @@ Ext.define('Proxmox.form.ComboGrid', {
         return picker;
     },
 
+    clearLocalFilter: function() {
+        var me = this,
+            filter = me.queryFilter;
+
+        if (filter) {
+            me.queryFilter = null;
+            me.changingFilters = true;
+            me.store.removeFilter(filter, true);
+            me.changingFilters = false;
+        }
+    },
+
     isValueInStore: function(value) {
        var me = this;
        var store = me.store;
@@ -319,6 +331,13 @@ Ext.define('Proxmox.form.ComboGrid', {
            return found;
        }
 
+       // Make sure the current filter is removed before checking the store
+       // to prevent false negative results when iterating over a filtered store.
+       // All store.find*() method's operate on the filtered store.
+       if (me.queryFilter && me.queryMode === 'local' && me.clearFilterOnBlur) {
+           me.clearLocalFilter();
+       }
+
        if (Ext.isArray(value)) {
            Ext.Array.each(value, function(v) {
                if (store.findRecord(me.valueField, v)) {