From 0b2f6a20daf8191dc6ca2dc0b95a4962a022efde Mon Sep 17 00:00:00 2001 From: brenna Date: Mon, 29 Feb 2016 11:45:32 -0500 Subject: [PATCH 1/2] 0.8.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8397d89..53d3d62 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ember-searchable-select", - "version": "0.7.0", + "version": "0.8.0", "description": "Data-down, actions up select-like menu with searching and filtering capabilities.", "directories": { "doc": "doc", From aa5f52aafee3b24f7d2e08c4e9c82901e07d590f Mon Sep 17 00:00:00 2001 From: brenna Date: Mon, 29 Feb 2016 18:11:38 -0500 Subject: [PATCH 2/2] fix false positive test on optional menu close, #31 --- addon/components/searchable-select.js | 13 +++++++++---- addon/templates/components/searchable-select.hbs | 2 +- .../components/searchable-select-test.js | 3 ++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/addon/components/searchable-select.js b/addon/components/searchable-select.js index 1dbc631..12536cb 100644 --- a/addon/components/searchable-select.js +++ b/addon/components/searchable-select.js @@ -160,9 +160,12 @@ export default Ember.Component.extend({ _bindOutsideClicks() { let component = this; - $(window).one(`click.${component.elementId}`, function() { - component.send('hideMenu'); - component.$('.Searchable-select__label').blur(); + let componentElem = this.get('element'); + $(window).on(`click.${component.elementId}`, function(e) { + if (!$.contains(componentElem, e.target)) { + component.send('hideMenu'); + component.$('.Searchable-select__label').blur(); + } }); }, @@ -284,7 +287,9 @@ export default Ember.Component.extend({ }, addNew() { this['on-add'].call(this, this.get('_searchText')); - this.send('hideMenu'); + if (this.get('closeOnSelection')) { + this.send('hideMenu'); + } }, noop() { // need an action to able to attach bubbles:false to an elem diff --git a/addon/templates/components/searchable-select.hbs b/addon/templates/components/searchable-select.hbs index 97025ab..c043d6a 100644 --- a/addon/templates/components/searchable-select.hbs +++ b/addon/templates/components/searchable-select.hbs @@ -114,7 +114,7 @@ searchText=_searchText optionLabelKey=optionLabelKey optionDisabledKey=optionDisabledKey - select-item=(action "selectItem")}} + select-item=(action "selectItem") }} {{/each}} {{/if}} diff --git a/tests/integration/components/searchable-select-test.js b/tests/integration/components/searchable-select-test.js index 3f3c0ac..095bb70 100644 --- a/tests/integration/components/searchable-select-test.js +++ b/tests/integration/components/searchable-select-test.js @@ -253,12 +253,13 @@ test('can disable the menu from closing after a selection is made', function(ass this.actions = { assertMenuOpen() { - assert.equal(this.$('.Searchable-select__options-list').length, 1); + assert.equal(this.$('.Searchable-select--menu-open').length, 1); } }; this.render(hbs`{{searchable-select content=content + closeOnSelection=false on-change=(action "assertMenuOpen")}}`); this.$('.Searchable-select__label').click();