Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[grid] Should not accept data from data provider callbacks that were already used #6584

Closed
vursen opened this issue Oct 2, 2023 · 0 comments · Fixed by #6968
Closed

[grid] Should not accept data from data provider callbacks that were already used #6584

vursen opened this issue Oct 2, 2023 · 0 comments · Fixed by #6968
Assignees

Comments

@vursen
Copy link
Contributor

vursen commented Oct 2, 2023

Description

A finding from #5961:

Currently, Grid tries to set new items and update the size whenever a data provider callback is called, regardless if there is a corresponding pending page request. This has at least several negative consequences:

  1. Data is accepted even if the same data provider callback was already called once.
  2. Data is accepted even if the cache was cleared while the page request was pending.

Besides, this doesn't align with combo-box which ignores such callback invocations.

Expected outcome

Invocations of a data provider callback should be ignored if that callback isn't present in the page queue.

Here is how it's done in combo-box:

const callback = (items, size) => {
if (this._pendingRequests[page] !== callback) {
return;
}

Minimal reproducible example

<script type="module">
  import '@vaadin/grid/all-imports';

  const grid = document.querySelector('vaadin-grid');
  grid.dataProvider = (params, callback) => {
    callback([{ title: 'Item 1' }, { title: 'Item 2' }], 2);
    callback([{ title: 'Malicious!' }], 1);
  }
</script>

<vaadin-grid>
  <vaadin-grid-column path="title"></vaadin-grid-column>
</vaadin-grid>

Steps to reproduce

  1. Add the above snippet to a page
  2. Observe "Malicious!" in the first row

Environment

Vaadin version(s): 24.3 and earlier
OS: Mac OS

Browsers

Issue is not browser related

@vursen vursen added bug Something isn't working vaadin-grid labels Oct 2, 2023
@vursen vursen changed the title [grid] Should not accept data from data provider callback when there is no corresponding page request [grid] Should not accept data from stale data provider callbacks Nov 24, 2023
@vursen vursen changed the title [grid] Should not accept data from stale data provider callbacks [grid] Should not accept data from data provider callbacks that were used once Nov 24, 2023
@vursen vursen changed the title [grid] Should not accept data from data provider callbacks that were used once [grid] Should not accept data from data provider callbacks that were already used Nov 24, 2023
@vursen vursen self-assigned this Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants