diff --git a/src/js/models/maps/viewfinder/ViewfinderModel.js b/src/js/models/maps/viewfinder/ViewfinderModel.js index fc94ac246..3d7e438ac 100644 --- a/src/js/models/maps/viewfinder/ViewfinderModel.js +++ b/src/js/models/maps/viewfinder/ViewfinderModel.js @@ -42,20 +42,13 @@ define( initialize({ mapModel }) { this.geocoderSearch = new GeocoderSearch(); this.mapModel = mapModel; - - this.autocompleteSearch = _.debounce( - this.notDebouncedAutocompleteSearch, - 250, // milliseconds - ); }, /** * Get autocompletion predictions from the GeocoderSearch model. - * This function should be debounced to prevent sending many requests to - * the API while the user is still typing. * @param {string} rawQuery is the user's search query with spaces. */ - async notDebouncedAutocompleteSearch(rawQuery) { + async autocompleteSearch(rawQuery) { const query = rawQuery.trim(); if (this.get('query') === query) { return; diff --git a/src/js/templates/maps/viewfinder/viewfinder-prediction.html b/src/js/templates/maps/viewfinder/viewfinder-prediction.html index 6f3329b5b..52715cf37 100644 --- a/src/js/templates/maps/viewfinder/viewfinder-prediction.html +++ b/src/js/templates/maps/viewfinder/viewfinder-prediction.html @@ -1,4 +1,7 @@ -
+
<%= description %> diff --git a/src/js/views/maps/viewfinder/PredictionView.js b/src/js/views/maps/viewfinder/PredictionView.js index b5cd6f2d1..13892d195 100644 --- a/src/js/views/maps/viewfinder/PredictionView.js +++ b/src/js/views/maps/viewfinder/PredictionView.js @@ -93,7 +93,6 @@ define( * sibling list elements. */ select(event) { - event.stopPropagation(); this.viewfinderModel.selectPrediction(this.predictionModel); }, @@ -104,7 +103,7 @@ define( * */ render() { const focusIndex = this.viewfinderModel.get('focusIndex'); - this.templateVars.isFocused = focusIndex !== -1 && focusIndex === this.index; + this.templateVars.isFocused = focusIndex === this.index; this.el.innerHTML = _.template(Template)(this.templateVars); }, diff --git a/test/js/specs/unit/models/maps/viewfinder/ViewfinderModel.spec.js b/test/js/specs/unit/models/maps/viewfinder/ViewfinderModel.spec.js index 3e91e93e1..7af8e3935 100644 --- a/test/js/specs/unit/models/maps/viewfinder/ViewfinderModel.spec.js +++ b/test/js/specs/unit/models/maps/viewfinder/ViewfinderModel.spec.js @@ -17,12 +17,6 @@ define( describe('ViewfinderModel Test Suite', () => { const state = cleanState(() => { const sandbox = sinon.createSandbox(); - // sinon.useFakeTimers() doesn't work with _.debounce, so stubbing instead. - const debounceStub = sandbox.stub(_, 'debounce').callsFake(function (fnToDebounce) { - return function (...args) { - fnToDebounce.apply(this, args); - }; - }); const model = new ViewfinderModel({ mapModel: new Map() }); const zoomSpy = sinon.spy(model.mapModel, 'zoomTo'); const autocompleteSpy = sandbox.stub(model.geocoderSearch, 'autocomplete').returns([]) @@ -46,7 +40,6 @@ define( return { autocompleteSpy, - debounceStub, geocodeSpy, model, predictions, @@ -118,10 +111,6 @@ define( expect(state.model.get('focusIndex')).to.equal(-1); }); - it('debounces autocomplete search using underscor\'s debounce', () => { - expect(state.debounceStub.callCount).to.equal(1); - }); - it('sets predictions from autocomplete search', async () => { const predictions = [new Prediction({ description: 'Some Other Location',