Skip to content

Commit d530b51

Browse files
authored
fix: Correctly render search nodes.🐛 (#117)
Fixes #111
1 parent 5a253c8 commit d530b51

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

docs/bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/src/stories/BigData/big-data2.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

src/tree/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import React, { Component } from 'react'
55
import TreeNode from '../tree-node'
66

77
const shouldRenderNode = (node, searchModeOn, data) => {
8+
if (node.hide) return false
89
if (searchModeOn || node.expanded) return true
910

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

5354
computeInstanceProps = props => {
5455
this.allVisibleNodes = this.getNodes(props)
55-
this.totalPages = this.allVisibleNodes.length / this.props.pageSize
56+
this.totalPages = Math.ceil(this.allVisibleNodes.length / this.props.pageSize)
5657
this.currentPage = 1
5758
}
5859

@@ -83,7 +84,7 @@ class Tree extends Component {
8384

8485
loadMore = () => {
8586
this.currentPage = this.currentPage + 1
86-
const nextItems = this.allVisibleNodes.slice(0, this.currentPage + this.props.pageSize)
87+
const nextItems = this.allVisibleNodes.slice(0, this.currentPage * this.props.pageSize)
8788
this.setState({ items: nextItems })
8889
}
8990

0 commit comments

Comments
 (0)