Skip to content

Commit

Permalink
Make the opening asynchronous
Browse files Browse the repository at this point in the history
  • Loading branch information
platosha authored and Saulis committed Jun 8, 2016
1 parent 4d5155f commit 4c7d529
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
16 changes: 12 additions & 4 deletions test/toggling-dropdown.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,27 @@
});

describe('opening', function() {
it('should open by tapping label', function() {
it('should open asynchronously by tapping label', function(done) {
Polymer.Base.fire('tap', {}, {
bubbles: true,
node: combobox.$$('paper-input-container label')
});

expect(combobox.opened).to.be.true;
expect(combobox.opened).to.be.false;
Polymer.Base.async(function() {
expect(combobox.opened).to.be.true;
done();
}, 1);
});

it('should open by clicking input', function() {
it('should open asynchronously by clicking input', function(done) {
combobox.$$('paper-input-container input').fire('tap');

expect(combobox.opened).to.be.true;
expect(combobox.opened).to.be.false;
Polymer.Base.async(function() {
expect(combobox.opened).to.be.true;
done();
}, 1);
});

it('should open by clicking icon', function() {
Expand Down
13 changes: 11 additions & 2 deletions vaadin-combo-box.html
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
invalid="[[invalid]]"
opened$="[[opened]]"
hideclear$="[[_hideClearIcon(value, opened)]]">
<label id="label" on-tap="open">[[label]]</label>
<label id="label" on-tap="_openAsync">[[label]]</label>
<input
is="iron-input"
id="input"
Expand All @@ -163,7 +163,7 @@
required$="[[required]]"
on-input="_inputValueChanged"
on-blur="_onBlur"
on-tap="open"
on-tap="_openAsync"
key-event-target>
<div suffix id="clearIcon" on-tap="_clear"
on-down="_preventDefault">
Expand Down Expand Up @@ -431,6 +431,15 @@
}
},

/**
* Opens the dropdown list asynchronously.
*/
_openAsync: function() {
// Needed for MS Edge. Otherwise, it does not pop the virtual keyboard up
// when tapping the combobox that has non-empty value.
this.async(this.open);
},

/**
* Opens and closes the dropdown list.
*/
Expand Down
2 changes: 1 addition & 1 deletion vaadin-overlay-behavior.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@

_setPosition: function(e) {
var parent = this._unwrapIfNeeded(this.parentElement);
if ((!e || e.target.contains(this) || e.target.contains(this.positionTarget)) && parent === document.body) {
if ((!e || e.target.contains && (e.target.contains(this) || e.target.contains(this.positionTarget))) && parent === document.body) {
var targetRect = this.positionTarget.getBoundingClientRect();
this._alignedAbove = this._shouldAlignAbove();

Expand Down

0 comments on commit 4c7d529

Please sign in to comment.