IE11 test

This commit is contained in:
Josh Johnson 2017-08-02 09:42:12 +01:00
parent 29ab3ca55a
commit 4d16787997
2 changed files with 34 additions and 3 deletions

View file

@ -1824,6 +1824,7 @@ class Choices {
_onMouseDown(e) {
const target = e.target;
// If we have our mouse down on the scrollbar and are on IE11...
if (target === this.choiceList && this.isIe11) {
this.isScrollingOnIe = true;
}
@ -2062,8 +2063,11 @@ class Choices {
blurActions[this.passedElement.type]();
} else {
this.input.focus();
// On IE11, clicking the scollbar blurs our input and thus
// closes the dropdown. To stop this, we refocus our input
// if we know we are on IE *and* are scrolling.
this.isScrollingOnIe = false;
this.input.focus();
}
}

View file

@ -383,8 +383,8 @@ describe('Choices', () => {
it('should close the dropdown on double click', function() {
this.choices = new Choices(this.input);
const container = this.choices.containerOuter,
openState = this.choices.config.classNames.openState;
const container = this.choices.containerOuter;
const openState = this.choices.config.classNames.openState;
this.choices._onClick({
target: container,
@ -401,6 +401,33 @@ describe('Choices', () => {
expect(document.activeElement === this.choices.input && container.classList.contains(openState)).toBe(false);
});
it('should set scrolling flag and not hide dropdown when scrolling on IE', function() {
this.choices = new Choices(this.input);
this.choices.isIe11 = true;
spyOn(this.choices, 'hideDropdown');
const container = this.choices.containerOuter;
const choiceList = this.choices.choiceList;
// Click to open dropdown
this.choices._onClick({
target: container,
ctrlKey: false,
preventDefault: () => {}
});
// Hold mouse on scrollbar
this.choices._onMouseDown({
target: choiceList,
ctrlKey: false,
preventDefault: () => {}
});
expect(this.choices.isScrollingOnIe).toBe(true);
expect(this.choices.hideDropdown).not.toHaveBeenCalled();
});
it('should trigger showDropdown on dropdown opening', function() {
this.choices = new Choices(this.input);
const container = this.choices.containerOuter;