mirror of
https://github.com/Choices-js/Choices.git
synced 2024-06-16 12:45:10 +02:00
Added showDropdown/hideDropdown events
This commit is contained in:
parent
930f84c005
commit
00af5279e9
974
assets/scripts/dist/choices.js
vendored
974
assets/scripts/dist/choices.js
vendored
File diff suppressed because it is too large
Load diff
2
assets/scripts/dist/choices.js.map
vendored
2
assets/scripts/dist/choices.js.map
vendored
File diff suppressed because one or more lines are too long
2
assets/scripts/dist/choices.min.js
vendored
2
assets/scripts/dist/choices.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -653,6 +653,8 @@ class Choices {
|
|||
this.input.focus();
|
||||
}
|
||||
|
||||
triggerEvent(this.passedElement, "showDropdown", {});
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -678,6 +680,8 @@ class Choices {
|
|||
this.input.blur();
|
||||
}
|
||||
|
||||
triggerEvent(this.passedElement, "hideDropdown", {});
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue