Skip to content
Snippets Groups Projects
Commit 04a1881c authored by Tom Robinson's avatar Tom Robinson
Browse files

Fix table page size calculation

parent 94dc3bb6
No related branches found
No related tags found
No related merge requests found
......@@ -43,8 +43,9 @@ export default class TableSimple extends Component {
componentDidUpdate() {
let headerHeight = ReactDOM.findDOMNode(this.refs.header).getBoundingClientRect().height;
let footerHeight = this.refs.footer ? ReactDOM.findDOMNode(this.refs.footer).getBoundingClientRect().height : 0;
let rowHeight = ReactDOM.findDOMNode(this.refs.firstRow).getBoundingClientRect().height + 1;
let pageSize = Math.floor((this.props.height - headerHeight) / rowHeight) || 1;
let pageSize = Math.floor((this.props.height - headerHeight - footerHeight) / rowHeight) || 1;
if (this.state.pageSize !== pageSize) {
this.setState({ pageSize });
}
......@@ -102,7 +103,7 @@ export default class TableSimple extends Component {
</div>
</div>
{ pageSize < rows.length ?
<div className="p1 flex flex-no-shrink flex-align-right">
<div ref="footer" className="p1 flex flex-no-shrink flex-align-right">
<span className="text-bold">Rows {start + 1}-{end + 1} of {rows.length}</span>
<span className={cx("text-brand-hover px1 cursor-pointer", { disabled: start === 0 })} onClick={() => this.setState({ page: page - 1 })}>
<Icon name="left" height={10} />
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment