Skip to content

Commit

Permalink
Version 2.7.6
Browse files Browse the repository at this point in the history
  • Loading branch information
jshjohnson committed Mar 8, 2017
2 parents 63b50f5 + 4aa2a04 commit 13afb13
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 3 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,16 @@ example.passedElement.addEventListener('addItem', function(event) {
**Usage:** Triggered when a user types into an input to search choices.
### showDropdown
**Arguments:** - **Input types affected:** `select-one`, `select-multiple`
**Usage:** Triggered when the dropdown is shown.
### hideDropdown
**Arguments:** - **Input types affected:** `select-one`, `select-multiple`
**Usage:** Triggered when the dropdown is hidden.
## Methods
Methods can be called either directly or by chaining:
Expand Down
4 changes: 4 additions & 0 deletions assets/scripts/dist/choices.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/scripts/dist/choices.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/scripts/dist/choices.min.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions assets/scripts/src/choices.js
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,8 @@ class Choices {
this.input.focus();
}

triggerEvent(this.passedElement, "showDropdown", {});

return this;
}

Expand All @@ -678,6 +680,8 @@ class Choices {
this.input.blur();
}

triggerEvent(this.passedElement, "hideDropdown", {});

return this;
}

Expand Down
2 changes: 1 addition & 1 deletion assets/styles/scss/choices.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ $choices-keyline-color: #DDDDDD !default;
$choices-primary-color: #00BCD4 !default;
$choices-disabled-color: #eaeaea !default;
$choices-highlight-color: $choices-primary-color !default;
$choices-button-icon-path: '../../icons/' !default;
$choices-button-icon-path: '../../icons' !default;
$choices-button-dimension: 8px !default;
$choices-button-offset: 8px !default;

Expand Down
46 changes: 46 additions & 0 deletions tests/spec/choices_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,52 @@ describe('Choices', () => {
expect(document.activeElement === this.choices.input && container.classList.contains(openState)).toBe(false);
});

it('should trigger showDropdown on dropdown opening', function() {
this.choices = new Choices(this.input);
const container = this.choices.containerOuter;

const showDropdownSpy = jasmine.createSpy('showDropdownSpy');
const passedElement = this.choices.passedElement;

passedElement.addEventListener('showDropdown', showDropdownSpy);

this.choices.input.focus();

this.choices._onClick({
target: container,
ctrlKey: false,
preventDefault: () => {}
});

expect(showDropdownSpy).toHaveBeenCalled();
});

it('should trigger hideDropdown on dropdown closing', function() {
this.choices = new Choices(this.input);
const container = this.choices.containerOuter;

const hideDropdownSpy = jasmine.createSpy('hideDropdownSpy');
const passedElement = this.choices.passedElement;

passedElement.addEventListener('hideDropdown', hideDropdownSpy);

this.choices.input.focus();

this.choices._onClick({
target: container,
ctrlKey: false,
preventDefault: () => {}
});

this.choices._onClick({
target: container,
ctrlKey: false,
preventDefault: () => {}
});

expect(hideDropdownSpy).toHaveBeenCalled();
});

it('should filter choices when searching', function() {
this.choices = new Choices(this.input);

Expand Down

0 comments on commit 13afb13

Please sign in to comment.