Skip to content

Commit

Permalink
fix: Correctly render search nodes.🐛 (#117)
Browse files Browse the repository at this point in the history
Fixes #111
  • Loading branch information
mrchief authored Jun 6, 2018
1 parent 5a253c8 commit d530b51
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/bundle.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/src/stories/BigData/big-data2.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/tree/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import React, { Component } from 'react'
import TreeNode from '../tree-node'

const shouldRenderNode = (node, searchModeOn, data) => {
if (node.hide) return false
if (searchModeOn || node.expanded) return true

const parent = node._parent && data.get(node._parent)
Expand Down Expand Up @@ -52,7 +53,7 @@ class Tree extends Component {

computeInstanceProps = props => {
this.allVisibleNodes = this.getNodes(props)
this.totalPages = this.allVisibleNodes.length / this.props.pageSize
this.totalPages = Math.ceil(this.allVisibleNodes.length / this.props.pageSize)
this.currentPage = 1
}

Expand Down Expand Up @@ -83,7 +84,7 @@ class Tree extends Component {

loadMore = () => {
this.currentPage = this.currentPage + 1
const nextItems = this.allVisibleNodes.slice(0, this.currentPage + this.props.pageSize)
const nextItems = this.allVisibleNodes.slice(0, this.currentPage * this.props.pageSize)
this.setState({ items: nextItems })
}

Expand Down

0 comments on commit d530b51

Please sign in to comment.