Skip to content
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

InfiniteTree nodes/height not calculated correctly with flexbox #8

Open
frankvdb7 opened this issue Nov 25, 2017 · 4 comments
Open

Comments

@frankvdb7
Copy link

frankvdb7 commented Nov 25, 2017

When I try to use flexbox with the InfiniteTree component like this:

render() {
    return (
        <div style={{ display: "flex", flexDirection:"column" }}>
          <InfiniteTree
              width="100%"
              height="100%"
              style={{ flex: "1 1 auto" }}
              rowHeight={30}
              data={someData}
           />
        </div>
    )
}

The div and InfiniteTree container correctly expand to height 100% in the inspector, but the InfiniteTree component only shows 5 nodes instead of filling in rows until the 100% height. So lets say we have room for 10 nodes of 30 pixels (100% height = 300px), it only show 4 nodes of 30 pixels (120px), so there is 180px of empty space.

Is there a way to solve this?

Thanks

@aalbul
Copy link

aalbul commented Jan 15, 2018

Hi, i faced the same issue today.
Looks like react-tiny-virtual-list does not really support passing percentages to it.

screen shot 2018-01-15 at 11 15 50

According to this screenshot it treats it as a regular item and trying to add offset to it :)
Not sure what could be a solution to this though.

@cheton
Copy link
Owner

cheton commented Jan 16, 2018

As an alternative way, you may use the ref attribute and the ReactDOM.findDOMNode() function to get the offsetHeight of its container element, and then call this.setState({ height: containerElement.offsetHeight }) to trigger the second render.

@aalbul
Copy link

aalbul commented Jan 19, 2018

True. However:

  1. it will cause double rendering. I suppose it will be more visible if you have a big tree, but still
  2. react-infinite-tree states that it's possible to use string or number. Does it make sense to change documentation? :)

@cheton
Copy link
Owner

cheton commented Jan 20, 2018

I found a statement from react-tiny-virtual-list's documentation:

* Width may only be a string when scrollDirection is 'vertical'. Similarly, Height may only be a string if scrollDirection is 'horizontal'

Since react-infinite-tree's scroll direction is vertical, the "width" prop can either be a number or string like "100%" or "auto", but the "height" prop must be a number in this case.

I will update documentation accordingly. Also, I see some issues (clauderic/react-tiny-virtual-list#25, clauderic/react-tiny-virtual-list#37) and PRs there (clauderic/react-tiny-virtual-list#30, ), hope it can be merged soon.

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

No branches or pull requests

3 participants