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] Add onCompleteRender prop #1505

Merged
merged 19 commits into from
Aug 29, 2017
Merged

Conversation

cmslewis
Copy link
Contributor

@cmslewis cmslewis commented Aug 26, 2017

Fixes #1495

Checklist

  • Include tests
  • Update documentation (done automatically with new prop description)

Changes proposed in this pull request:

  • 💎 NEW Table now offers an onCompleteRender prop, invoked on mount/update when all cells in view have finished rendering.
  • 🐛 FIX Table no longer fires onVisibleCellsChange redundantly when the viewport hasn't actually changed.

Reviewers should focus on:

  • The callback is invoked when the MAIN quadrant's cells have finished loading, given that the MAIN quadrant is a superset of all other quadrants (TOP, LEFT, TOP_LEFT).
    • Since each quadrant's TableBody has a separate Batcher, it's possible to have a race condition wherein the MAIN quadrant cells finish rendering before the cells in other, smaller quadrants. One solution there would involve using a single batcher instance passed into the TableBody from the parent Table to properly queue cell rendering across all quadrants; we could also make the quadrants smarter by not double-rendering cells located underneath other quadrants. None of that is implemented in this PR, though, so we'll live with the potential for the race condition for now. What do you think?
  • This PR invokes onCompleteRender on mount and on update. But looking at the console logs in the table example, I'm not convinced that invoking this callback on update is actually helpful (for instance, the callback is invoked multiple times over the course of a single scroll interaction). Invoking onCompleteRender only on mount would still solve resizeByTallest doesn't work on mount because batch loader #1495. What do you think?

Screenshot

on-complete-render

@cmslewis cmslewis changed the base branch from master to cl/table-render-optimization-mode August 26, 2017 19:41
@@ -452,8 +457,8 @@ export class Table extends AbstractComponent<ITableProps, ITableState> {

return !Utils.shallowCompareKeys(this.props, nextProps, propKeysBlacklist)
|| !Utils.shallowCompareKeys(this.state, nextState, stateKeysBlacklist)
|| !Utils.deepCompareKeys(this.props, nextProps, ["selectedRegions"])
|| !Utils.deepCompareKeys(this.state, nextState, ["selectedRegions"]);
|| !Utils.deepCompareKeys(this.props, nextProps, Table.SHALLOW_COMPARE_PROP_KEYS_BLACKLIST)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These lists happen to be complementary, so I'm using the shallow-compare blacklists for the deep-compare whitelists. Is that too clever? Should I create separate Table.DEEP_COMPARE_{PROP,STATE}_KEYS_WHITELISTs for the sake of robustness? (I could still set those to equal the shallow-compare blacklist arrays, with a comment to clarify why that's okay.)

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure what you mean by this, so... um, possibly a comment anyways? What are you doing that's odd, exactly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Eh I think I was overthinking it. Fine as is IMO.

|| (viewportRect == null && nextViewportRect != null);

if (didViewportChange) {
this.invokeOnVisibleCellsChangeCallback(nextViewportRect);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Noticed we were invoking this even when the viewportRect values hadn't actually changed. This and the shouldComponentUpdate change address that double-invocation issue.

@blueprint-bot
Copy link

Invoke onVisibleCellsChange only when viewportRect actually changes

Preview: documentation | table
Coverage: core | datetime

@cmslewis cmslewis changed the base branch from cl/table-render-optimization-mode to master August 28, 2017 21:01
@cmslewis cmslewis force-pushed the cl/table-on-complete-render branch from 889277b to 1cb0d76 Compare August 28, 2017 21:04
@blueprint-bot
Copy link

Fix lint

Preview: documentation | table
Coverage: core | datetime

@@ -452,8 +457,8 @@ export class Table extends AbstractComponent<ITableProps, ITableState> {

return !Utils.shallowCompareKeys(this.props, nextProps, propKeysBlacklist)
|| !Utils.shallowCompareKeys(this.state, nextState, stateKeysBlacklist)
|| !Utils.deepCompareKeys(this.props, nextProps, ["selectedRegions"])
|| !Utils.deepCompareKeys(this.state, nextState, ["selectedRegions"]);
|| !Utils.deepCompareKeys(this.props, nextProps, Table.SHALLOW_COMPARE_PROP_KEYS_BLACKLIST)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure what you mean by this, so... um, possibly a comment anyways? What are you doing that's odd, exactly?

@blueprint-bot
Copy link

Merge branch 'master' into cl/table-on-complete-render

Preview: documentation | table
Coverage: core | datetime

@blueprint-bot
Copy link

Fewer rows so the test won't time out

Preview: documentation | table
Coverage: core | datetime

@cmslewis cmslewis merged commit 2f7c063 into master Aug 29, 2017
@cmslewis cmslewis deleted the cl/table-on-complete-render branch August 29, 2017 17:31
@cmslewis cmslewis mentioned this pull request Aug 30, 2017
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.

3 participants