Skip to content

Commit 64a460b

Browse files
committed
add couple short circuit for preventing bugs when search field is custom
1 parent c2d4f0a commit 64a460b

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/toolbar/ToolBar.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ class ToolBar extends Component {
3333
componentWillMount() {
3434
const delay = this.props.searchDelayTime ? this.props.searchDelayTime : 0;
3535
this.debounceCallback = this.handleDebounce(() => {
36-
this.props.onSearch(this.refs.seachInput.getValue());
36+
const { seachInput } = this.refs;
37+
seachInput && this.props.onSearch(seachInput.getValue());
3738
},
3839
delay
3940
);
@@ -44,8 +45,9 @@ class ToolBar extends Component {
4445
}
4546

4647
setSearchInput(text) {
47-
if (this.refs.seachInput.value !== text) {
48-
this.refs.seachInput.value = text;
48+
const { seachInput } = this.refs;
49+
if (seachInput && seachInput.value !== text) {
50+
seachInput.value = text;
4951
}
5052
}
5153

@@ -181,7 +183,8 @@ class ToolBar extends Component {
181183
}
182184

183185
handleClearBtnClick = () => {
184-
this.refs.seachInput.setValue('');
186+
const { seachInput } = this.refs;
187+
seachInput && seachInput.setValue('');
185188
this.props.onSearch('');
186189
}
187190

0 commit comments

Comments
 (0)