Skip to content

Commit

Permalink
Merge 51a41f8 into 810a5cf
Browse files Browse the repository at this point in the history
  • Loading branch information
Haprog committed Jun 10, 2019
2 parents 810a5cf + 51a41f8 commit 0b998d3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
6 changes: 6 additions & 0 deletions src/vaadin-combo-box-dropdown-wrapper.html
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,9 @@
}

_scrollIntoView(index) {
if (!(this.opened && index >= 0)) {
return;
}
const visibleItemsCount = this._visibleItemsCount();
if (visibleItemsCount === undefined) {
// Scroller is not visible. Moving is unnecessary.
Expand All @@ -360,6 +363,9 @@

if (index > this._selector.lastVisibleIndex - 1) {
// Index is below the bottom, scrolling down. Make the item appear at the bottom.
// First scroll to target (will be at the top of the scroller) to make sure it's rendered.
this._selector.scrollToIndex(index);
// Then calculate the index for the following scroll (to get the target to bottom of the scroller).
targetIndex = index - visibleItemsCount + 1;
} else if (index > this._selector.firstVisibleIndex) {
// The item is already visible, scrolling is unnecessary per se. But we need to trigger iron-list to set
Expand Down
14 changes: 5 additions & 9 deletions test/filtering.html
Original file line number Diff line number Diff line change
Expand Up @@ -385,15 +385,11 @@
comboBox = fixture('combobox');
});

it('should properly display all items in the selector', done => {
comboBox.opened = true;
setTimeout(() => {
comboBox.filteredItems = Array.apply(null, Array(20)).map((_, i) => `item${i}`);
setTimeout(() => {
expect(comboBox.$.overlay._selector.querySelectorAll('vaadin-combo-box-item').length).to.equal(20);
done();
}, 1);
});
it('should properly display all items in the selector', () => {
comboBox.open();
comboBox.filteredItems = Array.apply(null, Array(20)).map((_, i) => `item${i}`);
Polymer.flush();
expect(comboBox.$.overlay._selector.querySelectorAll('vaadin-combo-box-item').length).to.equal(20);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<script src="test-suites.js"></script>
</head>

<body>
<body style="min-height: 520px;">
<script>
WCT.loadSuites(window.VaadinComboBoxSuites);
</script>
Expand Down
1 change: 1 addition & 0 deletions test/keyboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@
});

it('should scroll down after reaching the last visible item', () => {
selector.scrollToIndex(0);
comboBox._focusedIndex = comboBox.$.overlay._visibleItemsCount() - 1;
expect(selector.firstVisibleIndex).to.eql(0);

Expand Down

0 comments on commit 0b998d3

Please sign in to comment.