[pve-devel] [PATCH widget-toolkit] fix comboBox validation when forceSelection is true
Tim Marx
t.marx at proxmox.com
Fri Oct 25 13:06:08 CEST 2019
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.
---
form/ComboGrid.js | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/form/ComboGrid.js b/form/ComboGrid.js
index c3e7782..6dac534 100644
--- a/form/ComboGrid.js
+++ b/form/ComboGrid.js
@@ -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)) {
--
2.20.1
More information about the pve-devel
mailing list