|
|
|
@ -39,7 +39,8 @@ class VirtualTable extends Component {
|
|
|
|
|
super(props, context);
|
|
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
|
width: 0
|
|
|
|
|
width: 0,
|
|
|
|
|
scrollRestored: false
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
this._grid = null;
|
|
|
|
@ -48,11 +49,13 @@ class VirtualTable extends Component {
|
|
|
|
|
componentDidUpdate(prevProps, prevState) {
|
|
|
|
|
const {
|
|
|
|
|
items,
|
|
|
|
|
scrollIndex
|
|
|
|
|
scrollIndex,
|
|
|
|
|
scrollTop
|
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
|
|
const {
|
|
|
|
|
width
|
|
|
|
|
width,
|
|
|
|
|
scrollRestored
|
|
|
|
|
} = this.state;
|
|
|
|
|
|
|
|
|
|
if (this._grid && (prevState.width !== width || hasDifferentItemsOrOrder(prevProps.items, items))) {
|
|
|
|
@ -60,6 +63,11 @@ class VirtualTable extends Component {
|
|
|
|
|
this._grid.recomputeGridSize();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this._grid && scrollTop !== undefined && scrollTop !== 0 && !scrollRestored) {
|
|
|
|
|
this.setState({ scrollRestored: true });
|
|
|
|
|
this._grid.scrollToPosition({ scrollTop });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (scrollIndex != null && scrollIndex !== prevProps.scrollIndex) {
|
|
|
|
|
this._grid.scrollToCell({
|
|
|
|
|
rowIndex: scrollIndex,
|
|
|
|
@ -137,6 +145,7 @@ class VirtualTable extends Component {
|
|
|
|
|
{header}
|
|
|
|
|
<div ref={registerChild}>
|
|
|
|
|
<Grid
|
|
|
|
|
{...otherProps}
|
|
|
|
|
ref={this.setGridRef}
|
|
|
|
|
autoContainerWidth={true}
|
|
|
|
|
autoHeight={true}
|
|
|
|
@ -158,7 +167,6 @@ class VirtualTable extends Component {
|
|
|
|
|
className={styles.tableBodyContainer}
|
|
|
|
|
style={gridStyle}
|
|
|
|
|
containerStyle={containerStyle}
|
|
|
|
|
{...otherProps}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</Scroller>
|
|
|
|
@ -176,6 +184,7 @@ VirtualTable.propTypes = {
|
|
|
|
|
className: PropTypes.string.isRequired,
|
|
|
|
|
items: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
|
|
|
scrollIndex: PropTypes.number,
|
|
|
|
|
scrollTop: PropTypes.number,
|
|
|
|
|
scroller: PropTypes.instanceOf(Element).isRequired,
|
|
|
|
|
header: PropTypes.node.isRequired,
|
|
|
|
|
headerHeight: PropTypes.number.isRequired,
|
|
|
|
|