Skip to content

Commit

Permalink
Merge pull request #34 from tedconf/patch/optional-clear
Browse files Browse the repository at this point in the history
patch/optional-close
  • Loading branch information
Brenna O'Brien committed Feb 29, 2016
2 parents 35ce610 + aa5f52a commit e17d58b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
13 changes: 9 additions & 4 deletions addon/components/searchable-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
});
},

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion addon/templates/components/searchable-select.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
searchText=_searchText
optionLabelKey=optionLabelKey
optionDisabledKey=optionDisabledKey
select-item=(action "selectItem")}}
select-item=(action "selectItem") }}
{{/each}}
</ul>
{{/if}}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/components/searchable-select-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit e17d58b

Please sign in to comment.