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

Revert "refactor: avoid unnecessary re-renders on virtualizer size change (#5650)" #7205

Merged
merged 13 commits into from
Mar 19, 2024

Conversation

vursen
Copy link
Contributor

@vursen vursen commented Mar 13, 2024

Description

The PR reverts #5650 due to several regressions mentioned below, and also adds tests that should prevent such regressions in the future.

Fixes #7079
Fixes #7186
Fixes #7160

Type of change

  • Revert

expect(item.getBoundingClientRect().top).to.be.closeTo(scrollTarget.getBoundingClientRect().top - 10, 1);
});

// FIXME: Fails due to a scroll offset reset caused by _adjustVirtualIndexOffset on scroll event.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a related issue to fix this?

Copy link
Contributor Author

@vursen vursen Mar 14, 2024

Choose a reason for hiding this comment

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

Good question. My plan was to report it after the merge because it's only reproducible with the scroll restoration logic.

@ugur-vaadin
Copy link
Contributor

As stated by @tomivirkki, this PR seems to also fix #7160. For that reason, I will move the test in the PR to fix that issue and close that one.

@@ -22,6 +22,13 @@ describe('unlimited size', () => {
el.index = index;
el.id = `item-${index}`;
el.textContent = el.id;
el.style.right = '0';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

note: Most of the styles are added to make debugging easier.

el.style.display = 'flex';
el.style.alignItems = 'center';
el.style.background = index % 2 === 0 ? '#e7e7e7' : '#d0d0d0';
el.style.height = '30px';
Copy link
Contributor Author

@vursen vursen Mar 18, 2024

Choose a reason for hiding this comment

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

note: Setting a fixed height prevents test failures related to differences in font rendering across browsers.

Copy link

Quality Gate Passed Quality Gate passed

Issues
2 New issues
0 Accepted issues

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

See analysis details on SonarCloud

@@ -184,40 +195,43 @@ describe('virtualizer', () => {
expect(item.getBoundingClientRect().top).to.equal(scrollTarget.getBoundingClientRect().top - 10);
});

it('should not request item updates on size increase', () => {
Copy link
Contributor Author

@vursen vursen Mar 18, 2024

Choose a reason for hiding this comment

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

note: After this PR is merged, I'll create an issue for further research on how to prevent item updates on size change without sacrificing the scroll restoration.

@vursen vursen merged commit 87653b4 into main Mar 19, 2024
9 checks passed
@vursen vursen deleted the revert-5650 branch March 19, 2024 06:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants