Skip to content

Commit

Permalink
Force next page request after clearCache (#774)
Browse files Browse the repository at this point in the history
Otherwise, if the dataProvider has returned an empty data set
previously, new data is not requested when opening the overlay after
clearCache()
  • Loading branch information
pekam authored and web-padawan committed Feb 13, 2019
1 parent 27242e3 commit ad2759f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/vaadin-combo-box-data-provider-mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@
}

_shouldLoadPage(page) {
if (!this.filteredItems) {
if (!this.filteredItems || this._forceNextRequest) {
this._forceNextRequest = false;
return true;
}

Expand Down Expand Up @@ -181,6 +182,8 @@
this.filteredItems = filteredItems;
if (this.opened) {
this._loadPage(0);
} else {
this._forceNextRequest = true;
}
}

Expand Down
18 changes: 18 additions & 0 deletions test/lazy-loading.html
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,24 @@
expect(pages).to.contain(1);
});
});

describe('after empty data set loaded', () => {

const emptyDataProvider = sinon.spy((params, callback) => callback([], 0));

beforeEach(() => {
comboBox.dataProvider = emptyDataProvider;
comboBox.open();
comboBox.close();
emptyDataProvider.reset();
});

it('should request first page on open', () => {
comboBox.clearCache();
comboBox.open();
expect(emptyDataProvider).to.be.calledOnce;
});
});
});
};

Expand Down

0 comments on commit ad2759f

Please sign in to comment.