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

fix: update all rendered rows on flat size change from page response #7101

Merged
merged 7 commits into from
Apr 16, 2024

Conversation

tomivirkki
Copy link
Member

@tomivirkki tomivirkki commented Jan 23, 2024

Description

The PR causes grid to update all rendered rows once it receives a page response that affects the flat size. This guarantees that all pages associated with the rendered rows are loaded.

Warning

It's been decided to wait until vaadin/flow#19006 is fixed, as it's currently causing interference in many scenarios related to the current regression, making it difficult to distinguish the causes.

Fixes #7097

Type of change

Bugfix

@@ -247,6 +255,15 @@ describe('data provider', () => {
{ path: 'name', direction: 'asc' },
]);
});

it('should not request again when resolving with an empty array', async () => {
Copy link
Member Author

@tomivirkki tomivirkki Jan 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of my earlier fix attempts passed all other tests but it caused an infinite data request loop when the callback was resolved with an empty array, so I added this test to make sure some future change will not cause this issue.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing with the same TreeGridScrollToPage mentioned in the ticket, I still get some odd behavior when expanding all items:

Bildschirmfoto 2024-01-24 um 09 23 47

It now loads more second level items (Dad *), but not the children for all of them, and doesn't show them as expanded. It breaks similarly if I increase the page size to 10 again. It works fine with page size 10 if I don't use the changes from this PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turns out that applying this fix, or alternatively, reverting the original regression, were both feasible options up until this change in the Flow Grid connector. Investigating the reason...

Copy link
Contributor

@vursen vursen Mar 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some investigation and found that Sascha's issue is actually a side effect of not just one but two changes:

A response with children for Granddad 0 changes the flat size which triggers the new logic added in this PR. The response contains only the first page while the virtualizer range also includes the second page. Therefore, the new logic immediately requests the second page for the sub-level of Granddad 0. The requested page gets into parentRequestDebouncer where it remains scheduled for a while. However, by the time the debouncer flushes, the page ends up far out of the viewport because Dad 0/0 is also expanded and by this time it has already received the sub-items (Flow sends the data for it in advance, in the same round-trip as the response for Granddad 0). Since the page is now out of the rendered range, the request range is reset to only request that second page. This causes Flow to clear the first page which doesn't get re-requested later, possibly due to #7097 (comment).

Copy link
Contributor

@vursen vursen Mar 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This explains why moving the new logic to _debouncerApplyCachedData deals with the issue. It delays the new logic until all requests are resolved, which helps avoid that request for the second page.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've moved the logic to the debouncer. Could you please confirm that the issue is no longer reproducible, @sissbruecker?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can still reproduce it when:

  • Scroll to end
  • Expand all
  • Scroll up

Also seems to happen sometimes when expanding all without scrolling down, but I couldn't identify a pattern.

Bildschirmaufnahme.2024-03-21.um.09.32.40.mov

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, let me check.

Copy link
Contributor

@vursen vursen Mar 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be caused by the key mapper issue again, rather than the current regression. I'm now inclined to wait until the key mapper issue is resolved, as it's currently causing interference in many scenarios.

Copy link
Contributor

@vursen vursen Apr 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can still reproduce it when:

Now that vaadin/flow#19006 has been fixed, I cannot reproduce this issue anymore. Can you please confirm, @sissbruecker?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vursen I also verified that the issue no longer reproduces after vaadin/flow#19006 is fixed.

@tomivirkki tomivirkki marked this pull request as draft January 31, 2024 11:32
Copy link

sonarcloud bot commented Feb 12, 2024

Quality Gate Passed Quality Gate passed

Issues
1 New issue

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@yuriy-fix yuriy-fix changed the title fix: check for grid rows without items after page received [BLOCKED] fix: check for grid rows without items after page received Feb 28, 2024
@vursen vursen force-pushed the fix/grid/small-page-size-missing-items branch 4 times, most recently from 20d8e44 to d97a205 Compare March 20, 2024 11:32
@vursen vursen changed the title [BLOCKED] fix: check for grid rows without items after page received [BLOCKED] fix: update all rendered rows on flat size change Mar 20, 2024
@vursen vursen changed the title [BLOCKED] fix: update all rendered rows on flat size change fix: update all rendered rows on flat size change Mar 20, 2024
@vursen vursen changed the title fix: update all rendered rows on flat size change fix: update all rendered rows on flat size change from a page response Mar 20, 2024
@vursen vursen marked this pull request as ready for review March 20, 2024 13:03
@vursen vursen changed the title fix: update all rendered rows on flat size change from a page response [BLOCKED] fix: update all rendered rows on flat size change from page response Mar 21, 2024
@vursen vursen force-pushed the fix/grid/small-page-size-missing-items branch from f2a6548 to a176c08 Compare April 11, 2024 13:31
Copy link

sonarcloud bot commented Apr 11, 2024

Quality Gate Passed Quality Gate passed

Issues
4 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@vursen vursen changed the title [BLOCKED] fix: update all rendered rows on flat size change from page response fix: update all rendered rows on flat size change from page response Apr 12, 2024
Copy link
Contributor

@DiegoCardoso DiegoCardoso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't see the issue with the provided example

@vursen vursen removed the request for review from sissbruecker April 16, 2024 09:39
@vursen vursen merged commit c7027bb into main Apr 16, 2024
9 checks passed
@vursen vursen deleted the fix/grid/small-page-size-missing-items branch April 16, 2024 09:50
@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with Vaadin 24.4.0.alpha24 and is also targeting the upcoming stable 24.4.0 version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[TreeGrid] Some items are missing after expanding all rows with small page size
5 participants