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

[Table] Call onVisibleCellsChange on scroll (in React 16.x) #2267

Merged
merged 1 commit into from
Mar 19, 2018

Conversation

mrshll
Copy link
Contributor

@mrshll mrshll commented Mar 19, 2018

Fixes #1974

Changes proposed in this pull request:

From: #1974

The issues lies in updateViewportRect method in table.tsx.

Code below:

this.setState({ viewportRect: nextViewportRect });
const { viewportRect } = this.state;

const didViewportChange =
            (viewportRect != null && !viewportRect.equals(nextViewportRect)) ||
            (viewportRect == null && nextViewportRect != null);

is incorrect because viewportRect is destructured after the setState. React recent updates have changed the way setState is executed and state may be set immediately, thus causing didViewportChange to be false and the onVisibleCellsChange to not be invoked. Simply swapping the first two lines fixes the issue.

Reviewers should focus on:

didViewportChange working properly. The table performance perhaps improving via: #1664

@palantirtech
Copy link
Member

Thanks for your interest in palantir/blueprint, @mmoutenot! Before we can accept your pull request, you need to sign our contributor license agreement - just visit https://cla.palantir.com/ and follow the instructions. Once you sign, I'll automatically update this pull request.

@giladgray giladgray requested a review from themadcreator March 19, 2018 18:08
@llorca llorca changed the title fix #1974 [Table] Call onVisibleCellsChange on scroll (in React 16.x) Mar 19, 2018
Copy link
Contributor

@themadcreator themadcreator left a comment

Choose a reason for hiding this comment

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

There are probably other subtle issues that we'll find with the semantic changes to .setState but this is good fix.

@themadcreator themadcreator merged commit 058cb3e into palantir:develop Mar 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Table] onVisibleCellsChange not called on scroll in React 16.x
3 participants