Ticket #5974: 5974.3.patch
| File 5974.3.patch, 3.8 kB (added by haysmark, 7 months ago) |
|---|
-
form/ComboBox.js
1063 1063 // summary: 1064 1064 // See dojo.data.util.simpleFetch.fetch() 1065 1065 if(!args.query){ args.query = {}; } 1066 if(!args.query.name){ args.query.name = " *"; }1066 if(!args.query.name){ args.query.name = ""; } 1067 1067 if(!args.queryOptions){ args.queryOptions = {}; } 1068 1068 var query = "^" + args.query.name 1069 1069 .replace(/([\\\|\(\)\[\{\^\$\+\?\.\<\>])/g, "\\$1") -
form/FilteringSelect.js
29 29 // 30 30 _isvalid:true, 31 31 32 required:true, 33 32 34 _lastDisplayedValue: "", 33 35 34 36 isValid:function(){ 35 return this._isvalid ;37 return this._isvalid||(!this.required&&this.getDisplayedValue()==""); // #5974 36 38 }, 37 39 38 40 _callbackSetLabel: function( /*Array*/ result, … … 45 47 // setValue does a synchronous lookup, 46 48 // so it calls _callbackSetLabel directly, 47 49 // and so does not pass dataObject 48 // dataObject==null means do not test the lastQuery, just continue49 if( dataObject && dataObject.query[this.searchAttr] != this._lastQuery){50 // still need to test against _lastQuery in case it came too late 51 if((dataObject && dataObject.query[this.searchAttr] != this._lastQuery)||(!dataObject&&this.store.getIdentity(result[0])!= this._lastQuery)){ 50 52 return; 51 53 } 52 54 if(!result.length){ 53 55 //#3268: do nothing on bad input 54 56 //this._setValue("", ""); 55 57 //#3285: change CSS to indicate error 56 if(!this._focused){ this.valueNode.value= ""; }57 dijit.form.TextBox.superclass.setValue.call(this, undefined, !this._focused);58 if(!this._focused){ this.valueNode.value=null; } 59 dijit.form.TextBox.superclass.setValue.call(this, null, !this._focused); 58 60 this._isvalid=false; 59 61 this.validate(this._focused); 62 this.item=null; 60 63 }else{ 61 64 this._setValueFromItem(result[0], priorityChange); 62 65 } … … 74 77 75 78 getValue:function(){ 76 79 // don't get the textbox value but rather the previously set hidden value 77 return this. valueNode.value;80 return this.isValid()?this.valueNode.value:null; 78 81 }, 79 82 80 83 _getValueField:function(){ … … 94 97 // summary 95 98 // Sets the value of the select. 96 99 // Also sets the label to the corresponding value by reverse lookup. 100 this._lastQuery=value; 101 // #5974: setValue(null) should clear input 102 if(!value){ 103 this.setDisplayedValue("",priorityChange); 104 return; 105 } 97 106 98 107 //#3347: fetchItemByIdentity if no keyAttr specified 99 108 var self=this; … … 178 187 }, 179 188 onError: function(errText){ 180 189 console.error('dijit.form.FilteringSelect: ' + errText); 181 dojo.hitch(_this, "_setValue")( undefined, label, false);190 dojo.hitch(_this, "_setValue")(null, label, false); 182 191 } 183 192 }); 184 193 } -
tests/form/test_FilteringSelect.html
68 68 <hr> 69 69 70 70 <form action="#" method="GET"> 71 <p>FilteringSelect #1: inlined data, autoComplete=false :</p>71 <p>FilteringSelect #1: inlined data, autoComplete=false, required="false":</p> 72 72 <label for="setvaluetest2">state list 1:</label> 73 73 <select dojoType="dijit.form.FilteringSelect" 74 74 id="setvaluetest2" … … 78 78 onChange="dojo.byId('oc1').value=arguments[0]" 79 79 onFocus="console.log('user focus handler')" 80 80 onBlur="console.log('user blur handler')" 81 required="false" 81 82 > 82 <option value="blank"></option>83 83 <option value="AL">Alabama</option> 84 84 <option value="AK">Alaska</option> 85 85 <option value="AS">American Samoa</option>