Skip to content

Commit

Permalink
fix: reposition overlay after first page load (#814)
Browse files Browse the repository at this point in the history
only if the number of items to render has increased from a previous rendering

fix vaadin/vaadin-combo-box-flow#250
  • Loading branch information
pekam committed Jun 5, 2019
1 parent 752e870 commit 810a5cf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/vaadin-combo-box-data-provider-mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@
if (Object.keys(this._pendingRequests).length === 0) {
this.loading = false;
}
if (page === 0 && this.__repositionOverlayDebouncer && items.length > (this.__maxRenderedItems || 0)) {
setTimeout(() => this.__repositionOverlayDebouncer.flush());
this.__maxRenderedItems = items.length;
}
}
};
this._pendingRequests[page] = callback;
Expand Down
17 changes: 17 additions & 0 deletions test/lazy-loading.html
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,23 @@
comboBox.open();
expect(dp).to.be.calledOnce;
});

it('should render all visible items after delayed response', done => {
const items = [...Array(10)].map((_, i) => 'item ' + i);
comboBox.dataProvider = (params, callback) => {
setTimeout(() => {
callback(items, 10);
setTimeout(() => {
const renderedTexts = Array.from(comboBox.$.overlay._selector
.querySelectorAll('vaadin-combo-box-item'))
.map(i => i.shadowRoot.querySelector('#content').innerText);
expect(renderedTexts).to.eql(items);
done();
});
}, 50);
};
comboBox.open();
});
});

describe('when selecting item', () => {
Expand Down

0 comments on commit 810a5cf

Please sign in to comment.