-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Make scroll offset uncontrollable in favor of ref methods #1320
Make scroll offset uncontrollable in favor of ref methods #1320
Conversation
* Grid component - Make Grid uncontrollable, rename scrollTop/scrollLeft props to defaultScrollTop/defaultScrollLeft (only to be used on mount) - Limit scrollTop and scrollLeft to maximum possible values before state update in scrollToPosition method(prevents rendering issues when calling scrollToPosition multiple times with values larger than max) - Update tests and docs * MultiGrid component - Remove scrollLeft and scrollTop from state - Remove getDerivedStateFromProps and state handling code from componentDidMount - Update all _onScroll methods to use scrollToPosition for syncing - Add scrollToPosition method (pass-thru that calls scrollToPosition of the main scrolling grid which is _bottomRightGrid) - Update tests and docs * List component - Make List uncontrollable, rename scrollTop to defaultScrollTop (only to be used on mount) - Update tests and docs * Table component - Make Table uncontrollable, rename scrollTop to defaultScrollTop (only to be used on mount) - Update tests and docs * ScrollSync component - Add flow types - Add registerChild to children render function parameters - Implement _registerChild to store refs on scrollable children - Call scrollToPosition on children refs in _onScroll handler to sync them - Update tests, docs and example * WindowScroller component - Update flow types - Rename existing registerChild method to registerChildContainer - Add registerChild to children render function parameters - Implement _registerChild to store ref on scrollable child - Call scrollToPosition on child ref in _handleWindowScrollEvent handler - Update tests, docs and example
@somi92 Thanks for doing this! I'll take some time soon to thoroughly review this and test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple comment about how we're handing null checks & other small things.
This is AMAZING 💯
"ScrollSync registerChild expects to be passed a component with 'scrollToPosition' function", | ||
); | ||
} | ||
this._elements.push(element); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we register if its falsey?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, probably not, there is no much sense in keeping the element in that case. I'll fix this!
@wuweiweiwu Thanks! I'm a bit short on time for a couple of days but will respond to your remarks by Tuesday. |
@somi92 No problem! Take your time :) Your effort on this has been very much appreciated |
Codecov Report
@@ Coverage Diff @@
## master #1320 +/- ##
==========================================
- Coverage 94.7% 94.44% -0.27%
==========================================
Files 47 47
Lines 1795 1800 +5
==========================================
Hits 1700 1700
- Misses 95 100 +5
Continue to review full report at Codecov.
|
Changes based on discussion from #999.
Summary of changes:
Grid component
MultiGrid component
List component
Table component
ScrollSync component
WindowScroller component
handler
Thanks for contributing to react-virtualized!
Before submitting a pull request, please complete the following checklist:
npm test
) all passnpm run prettier
).npm run typecheck
).Here is a short checklist of additional things to keep in mind before submitting: