Skip to content

Commit

Permalink
Do not incur cost of filtering tree if search mode is off
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddhartha Gandhi committed Jul 13, 2022
1 parent 1e891d0 commit e57d4ef
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,18 +148,22 @@ class DropdownTreeSelect extends Component {
}

onInputChange = value => {
const { allNodesHidden, tree } = this.treeManager.filterTree(
value,
this.props.keepTreeOnSearch,
this.props.keepChildrenOnSearch
)
const searchModeOn = value.length > 0

this.setState({
tree,
searchModeOn,
allNodesHidden,
})
if (!searchModeOn) {
this.setState(this.resetSearchState())
}
else {
const { allNodesHidden, tree } = this.treeManager.filterTree(
value,
this.props.keepTreeOnSearch,
this.props.keepChildrenOnSearch
)
this.setState({
tree,
searchModeOn,
allNodesHidden,
})
}
}

onTagRemove = (id, isKeyboardEvent) => {
Expand Down

0 comments on commit e57d4ef

Please sign in to comment.