diff --git a/src/autocomplete/dropdown.js b/src/autocomplete/dropdown.js index 85c9b9a11..7feee4c8b 100644 --- a/src/autocomplete/dropdown.js +++ b/src/autocomplete/dropdown.js @@ -62,6 +62,7 @@ function Dropdown(o) { _.className(this.cssClasses.prefix, this.cssClasses.empty, true) + '">' + ''); this.$menu.append(this.$empty); + this.$empty.hide(); } this.datasets = _.map(o.datasets, function(oDataset) { @@ -148,6 +149,7 @@ _.mixin(Dropdown.prototype, EventEmitter, { query: this.datasets[0] && this.datasets[0].query }); this.$empty.html(html); + this.$empty.show(); this._show(); } } else if (_.any(this.datasets, hasEmptyTemplate)) { @@ -162,6 +164,7 @@ _.mixin(Dropdown.prototype, EventEmitter, { } else if (this.isOpen) { if (this.$empty) { this.$empty.empty(); + this.$empty.hide(); } if (query.length >= this.minLength) { diff --git a/test/unit/dropdown_spec.js b/test/unit/dropdown_spec.js index d5685a3de..093342515 100644 --- a/test/unit/dropdown_spec.js +++ b/test/unit/dropdown_spec.js @@ -91,6 +91,7 @@ describe('Dropdown', function() { it('should include the empty', function() { expect(this.$menu.find('.aa-empty').length).toEqual(1); expect(this.$menu.find('.aa-empty').children().length).toEqual(0); + expect(this.$menu.find('.aa-empty').css('display')).toEqual('none'); }); it('should not hide the dropdown if empty', function() { @@ -102,6 +103,7 @@ describe('Dropdown', function() { expect(this.$menu.find('.aa-empty').length).toEqual(1); expect(this.$menu.find('.aa-empty').children().length).toEqual(1); expect(this.$menu.find('.aa-empty').find('h3.empty').length).toEqual(1); + expect(this.$menu.find('.aa-empty').css('display')).not.toEqual('none'); }); it('should trigger empty', function() { @@ -126,6 +128,7 @@ describe('Dropdown', function() { this.view._onRendered('rendered', 'te'); expect(spy).not.toHaveBeenCalled(); + expect(this.$menu.find('.aa-empty').css('display')).toEqual('none'); }); });