Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

onContentHeightChange is not getting called after rowHeightGetter returns new value #292

Open
vitosamson opened this issue Oct 29, 2015 · 0 comments

Comments

@vitosamson
Copy link

As far as I can tell it's only running once when the component mounts.

rowHeightGetter:

  rowHeightGetter(index) {
    const tableRef = $(this.tableRef);
    const tableRows = tableRef.find('.public_fixedDataTable_bodyRow');
    const thisRow = tableRows.get(index);

    const cells = $(thisRow).find('.public_fixedDataTableCell_cellContent');
    const cellHeights = cells.map((idx, cell) => cell.scrollHeight).sort();
    const largestCell = cellHeights[cellHeights.length - 1];

    return largestCell && largestCell > 50 ? largestCell : 50;
  }

onContentHeightChange:

  onContentHeightChange(contentHeight) {
    this.setState({
      tableHeight: contentHeight
    });
  }

table:

  <Table
    rowHeight={50}
    rowHeightGetter={this.rowHeightGetter.bind(this)}
    height={this.state.tableHeight}
    onContentHeightChange={this.onContentHeightChange.bind(this)}
    ref="table"
  >

The first time rowHeightGetter is called it always returns 50 because the rows haven't been rendered yet. Once the rows have been rendered it gets called again and the row height updates (there's about a 500ms delay which I'm also trying to fix) but onContentHeightChange does not get called again, and so if any of the rows grew in height, the table cuts them off at the bottom.

I threw some console.logs into each function and confirmed that onContentHeightChange is not being called after rowHeightGetter returns the new values.

fixed-data-table 0.4.7
react 0.14.0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant