Skip to content

Commit

Permalink
Merge pull request #685 from vaadin/fix/focusout-problem-edge
Browse files Browse the repository at this point in the history
Fix problem with focusout happening when clicking on scroll bar on Edge
  • Loading branch information
platosha committed Jul 24, 2018
2 parents f6cb162 + 106a944 commit 3ec7786
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/vaadin-combo-box-dropdown.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
display: none;
}
</style>
<vaadin-combo-box-overlay id="overlay" hidden$="[[hidden]]" opened="[[opened]]" template="{{template}}" style="align-items: stretch; margin: 0">
<vaadin-combo-box-overlay id="overlay" hidden$="[[hidden]]" opened="[[opened]]" template="{{template}}" style="align-items: stretch; margin: 0;">
<slot></slot>
</vaadin-combo-box-overlay>
</template>
Expand Down
5 changes: 5 additions & 0 deletions src/vaadin-combo-box-mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@
super.ready();

this.addEventListener('focusout', e => {
// Fixes the problem with `focusout` happening when clicking on the scroll bar on Edge
if (e.relatedTarget === this.$.overlay.$.dropdown.$.overlay) {
e.composedPath()[0].focus();
return;
}
if (!this._closeOnBlurIsPrevented) {
this.close();
}
Expand Down
18 changes: 18 additions & 0 deletions test/scrolling.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,24 @@
done();
}, 1);
});

it('should not close the items when touching scroll bar', () => {
combobox.open();
const e = new CustomEvent('focusout', {bubbles: true, composed: true});
e.relatedTarget = combobox.$.overlay.$.dropdown.$.overlay;
combobox.inputElement.dispatchEvent(e);

expect(combobox.opened).to.be.true;
});

it('should keep the input focused while scrolling', () => {
combobox.open();
const e = new CustomEvent('focusout', {bubbles: true, composed: true});
e.relatedTarget = combobox.$.overlay.$.dropdown.$.overlay;
combobox.inputElement.dispatchEvent(e);

expect(combobox.inputElement.hasAttribute('focused')).to.be.true;
});
});
});
</script>
Expand Down

0 comments on commit 3ec7786

Please sign in to comment.