Changeset 12764

Show
Ignore:
Timestamp:
02/28/08 09:32:25 (11 months ago)
Author:
doughays
Message:

References #5970. Proxy commit for haysmark.
Set lastQuery sooner so that the user's text is not overwritten when an old query returns before the searchDelay expires.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • dijit/trunk/form/ComboBox.js

    r12727 r12764  
    267267                                // need to wait a tad before start search so that the event 
    268268                                // bubbles through DOM and we have value visible 
    269                                 this.searchTimer = setTimeout(dojo.hitch(this, "_startSearchFromInput"), this.searchDelay); 
     269                                setTimeout(dojo.hitch(this, "_startSearchFromInput"),1); 
    270270                        } 
    271271                }, 
     
    523523                        var query = dojo.clone(this.query); // #5970 
    524524                        this._lastQuery = query[this.searchAttr] = this._getQueryString(key); 
    525                         var _this = this; 
    526                         var dataObject = this.store.fetch({ 
    527                                 queryOptions: { 
    528                                         ignoreCase: this.ignoreCase,  
    529                                         deep: true 
    530                                 }, 
    531                                 query: query, 
    532                                 onComplete: dojo.hitch(this, "_openResultList"),  
    533                                 onError: function(errText){ 
    534                                         console.error('dijit.form.ComboBox: ' + errText); 
    535                                         dojo.hitch(_this, "_hideResultList")(); 
    536                                 }, 
    537                                 start:0, 
    538                                 count:this.pageSize 
    539                         }); 
    540  
    541                         var nextSearch = function(dataObject, direction){ 
    542                                 dataObject.start += dataObject.count*direction; 
    543                                 // #4091: 
    544                                 //              tell callback the direction of the paging so the screen 
    545                                 //              reader knows which menu option to shout 
    546                                 dataObject.direction = direction; 
    547                                 this.store.fetch(dataObject); 
    548                         } 
    549                         this._nextSearch = this._popupWidget.onPage = dojo.hitch(this, nextSearch, dataObject); 
     525                        // #5970: set _lastQuery, *then* start the timeout 
     526                        // otherwise, if the user types and the last query returns before the timeout, 
     527                        // _lastQuery won't be set and their input gets rewritten 
     528                        this.searchTimer=setTimeout(dojo.hitch(this, function(query, _this){ 
     529                                var dataObject = this.store.fetch({ 
     530                                        queryOptions: { 
     531                                                ignoreCase: this.ignoreCase,  
     532                                                deep: true 
     533                                        }, 
     534                                        query: query, 
     535                                        onComplete: dojo.hitch(this, "_openResultList"),  
     536                                        onError: function(errText){ 
     537                                                console.error('dijit.form.ComboBox: ' + errText); 
     538                                                dojo.hitch(_this, "_hideResultList")(); 
     539                                        }, 
     540                                        start:0, 
     541                                        count:this.pageSize 
     542                                }); 
     543 
     544                                var nextSearch = function(dataObject, direction){ 
     545                                        dataObject.start += dataObject.count*direction; 
     546                                        // #4091: 
     547                                        //              tell callback the direction of the paging so the screen 
     548                                        //              reader knows which menu option to shout 
     549                                        dataObject.direction = direction; 
     550                                        this.store.fetch(dataObject); 
     551                                } 
     552                                this._nextSearch = this._popupWidget.onPage = dojo.hitch(this, nextSearch, dataObject); 
     553                        }, query, this), this.searchDelay); 
    550554                }, 
    551555