CombBox is loading data twice
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.8k
- Forks
- 717
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 3
Description
Whenever user types a value into combobox input/filter, the underlying dataProvider is queried twice.
It may be tolerable for in-memory data providers, but it is extremely problematic with backend data providers.
The ComboBox behaved correctly until 8.6.0, the duplicate data provider query is unwanted consequence of fixes to issues
#11320 and #11341.
During DataCommunicator#reset() method, the beforeClientResponse() is eagerly invoked (and loading count+data from the provider). And when the combobox client receives them it asks for them once again.
See the following simple example and watch the stderr.
HorizontalLayout horizontal = new HorizontalLayout();
ComboBox<String> comboBox = new ComboBox<>();
comboBox.setDataProvider(new ListDataProvider<String>(Arrays.asList("blue", "red", "green", "purple", "grey", "orange")) {
@Override
public int size(Query<String, SerializablePredicate<String>> query) {
System.err.println("COUNT " + query.getFilter().orElse(null));
return super.size(query);
}
@Override
public Stream<String> fetch(Query<String, SerializablePredicate<String>> query) {
System.err.println("FETCH " + query.getLimit() + " " + query.getOffset() + " " + query.getFilter().orElse(null));
return super.fetch(query);
}
});
horizontal.addComponent(comboBox);
addComponent(horizontal);
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with DataCommunicator#reset() and its eager beforeClientResponse() call, then reproduce the issue with the ComboBox and custom ListDataProvider example. Trace the count and fetch requests after typing in the filter; done means each input causes only the intended data-provider query rather than a duplicate.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100