Skip to content

Commit

Permalink
feat: Do not incur cost of filtering tree if search mode is off (#580)
Browse files Browse the repository at this point in the history
Co-authored-by: Siddhartha Gandhi <[email protected]>
Co-authored-by: Hrusikesh Panda <[email protected]>
  • Loading branch information
3 people committed Jan 15, 2023
1 parent 58dec44 commit 591c9d7
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,18 +148,21 @@ 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 591c9d7

Please sign in to comment.