Skip to content

Commit 591c9d7

Browse files
gandhis1Siddhartha Gandhimrchief
committed
feat: Do not incur cost of filtering tree if search mode is off (dowjones#580)
Co-authored-by: Siddhartha Gandhi <siddhartha.gandhi@centivacapital.com> Co-authored-by: Hrusikesh Panda <mrchief@users.noreply.github.com>
1 parent 58dec44 commit 591c9d7

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

src/index.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -148,18 +148,21 @@ class DropdownTreeSelect extends Component {
148148
}
149149

150150
onInputChange = value => {
151-
const { allNodesHidden, tree } = this.treeManager.filterTree(
152-
value,
153-
this.props.keepTreeOnSearch,
154-
this.props.keepChildrenOnSearch
155-
)
156151
const searchModeOn = value.length > 0
157-
158-
this.setState({
159-
tree,
160-
searchModeOn,
161-
allNodesHidden,
162-
})
152+
if (!searchModeOn) {
153+
this.setState(this.resetSearchState())
154+
} else {
155+
const { allNodesHidden, tree } = this.treeManager.filterTree(
156+
value,
157+
this.props.keepTreeOnSearch,
158+
this.props.keepChildrenOnSearch
159+
)
160+
this.setState({
161+
tree,
162+
searchModeOn,
163+
allNodesHidden,
164+
})
165+
}
163166
}
164167

165168
onTagRemove = (id, isKeyboardEvent) => {

0 commit comments

Comments
 (0)