Skip to content

Commit

Permalink
Merge 36367b4 into 02a23b5
Browse files Browse the repository at this point in the history
  • Loading branch information
manolo committed Jul 24, 2018
2 parents 02a23b5 + 36367b4 commit a0595b3
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
13 changes: 11 additions & 2 deletions src/vaadin-combo-box-dropdown-wrapper.html
Expand Up @@ -28,7 +28,6 @@
}
</style>
<vaadin-combo-box-dropdown id="dropdown"
opened="{{opened}}"
hidden="[[_hidden(_items.*, loading)]]"
position-target="[[positionTarget]]"
on-template-changed="_templateChanged"
Expand Down Expand Up @@ -142,7 +141,7 @@
}

static get observers() {
return ['_selectorChanged(_selector)', '_loadingChanged(loading)'];
return ['_selectorChanged(_selector)', '_loadingChanged(loading)', '_openedChanged(opened)', '_itemsChanged(_items)'];
}

_fireTouchAction(sourceEvent) {
Expand All @@ -151,6 +150,16 @@
}));
}

_openedChanged(opened) {
this.$.dropdown.opened = !!(opened && this._items && this._items.length);
}

_itemsChanged(items) {
if (this.opened && !this.$.dropdown.opened && items && items.length) {
this.$.dropdown.opened = true;
}
}

ready() {
super.ready();
// IE11: when scrolling with mouse, the focus goes to the scroller.
Expand Down
7 changes: 5 additions & 2 deletions src/vaadin-combo-box-mixin.html
Expand Up @@ -261,8 +261,11 @@
this.focus();
}
}
} else if (this._openedWithFocusRing && this.hasAttribute('focused')) {
this.focusElement.setAttribute('focus-ring', '');
} else {
if (this._openedWithFocusRing && this.hasAttribute('focused')) {
this.focusElement.setAttribute('focus-ring', '');
}
this._onClosed();
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/overlay-position.html
Expand Up @@ -17,7 +17,7 @@

<test-fixture id='combobox'>
<template>
<vaadin-combo-box label='combobox' style='width: 300px'></vaadin-combo-box>
<vaadin-combo-box label='combobox' style='width: 300px' items='[1]'></vaadin-combo-box>
</template>
</test-fixture>

Expand Down
14 changes: 12 additions & 2 deletions test/toggling-dropdown.html
Expand Up @@ -308,7 +308,7 @@
});

it('dropdown should not be shown when disabled', () => {
combobox.inputElement.dispatchEvent(new CustomEvent('click'));
combobox.inputElement.dispatchEvent(new CustomEvent('click', {bubbles: true, composed: true}));
expect(combobox.opened).to.be.false;
});
});
Expand All @@ -328,7 +328,17 @@
});

it('dropdown should not be shown when read-only', () => {
combobox.inputElement.dispatchEvent(new CustomEvent('click'));
combobox.inputElement.dispatchEvent(new CustomEvent('click', {bubbles: true, composed: true}));
expect(combobox.opened).to.be.false;
});
});

describe('empty list', () => {
it('dropdown should not be shown when filteredItems is empty', () => {
combobox.filteredItems = null;
expect(combobox.opened).to.be.false;

combobox.filteredItems = [];
expect(combobox.opened).to.be.false;
});
});
Expand Down

0 comments on commit a0595b3

Please sign in to comment.