fix for missing rows in ManagedTable
Summary: When starting with an empty table and adding rows, the scrollOffset of the table might end up with a negative value, which causes rows not to be rendered. See https://github.com/bvaughn/react-window/issues/49 for more details. This only calls `scrollToItem` when the table is actually scrollable to prevent a negative scrollOffset. Reviewed By: passy Differential Revision: D9570518 fbshipit-source-id: 5b08990a353a6d41d0f1bc5c1481d5a5e471bd94
This commit is contained in:
committed by
Facebook Github Bot
parent
456e026257
commit
63c8bd4368
@@ -272,9 +272,19 @@ class ManagedTable extends React.Component<
|
|||||||
};
|
};
|
||||||
|
|
||||||
scrollToBottom() {
|
scrollToBottom() {
|
||||||
const {current} = this.tableRef;
|
const {current: tableRef} = this.tableRef;
|
||||||
if (current && this.props.rows.length > 1) {
|
const {current: scrollRef} = this.scrollRef;
|
||||||
current.scrollToItem(this.props.rows.length - 1);
|
if (!tableRef || !scrollRef) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// only call scrollToItem if the list is actually scrollable (height of the
|
||||||
|
// content is bigger than it's container). Otherwise this might cause
|
||||||
|
// problems: https://github.com/bvaughn/react-window/issues/49
|
||||||
|
const isScrollable = tableRef.props.height < scrollRef.offsetHeight;
|
||||||
|
|
||||||
|
if (tableRef && this.props.rows.length > 1 && isScrollable) {
|
||||||
|
tableRef.scrollToItem(this.props.rows.length - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user