Skip to content

Commit d601337

Browse files
committed
Merge pull request #364 from madeinfree/delay-search-issue
urgent to fixed the delay search bug.
2 parents 0928909 + 6df046d commit d601337

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

examples/js/manipulation/debounce-search-table.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ addProducts(5);
2424
export default class DebounceSearchTable extends React.Component {
2525
render() {
2626
const options = {
27-
searchDelayTime: 500
27+
searchDelayTime: 3000
2828
};
2929

3030
return (

src/toolbar/ToolBar.js

+12-7
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ class ToolBar extends Component {
2020
};
2121
}
2222

23+
componentWillMount() {
24+
const delay = this.props.searchDelayTime ? this.props.searchDelayTime : 0;
25+
this.debounceCallback = this.handleDebounce(() => {
26+
this.props.onSearch(this.refs.seachInput.value);
27+
},
28+
delay
29+
);
30+
}
31+
2332
componentWillUnmount() {
2433
this.clearTimeout();
2534
}
@@ -156,13 +165,9 @@ class ToolBar extends Component {
156165
};
157166
}
158167

159-
handleKeyUp = () => {
160-
const delay = this.props.searchDelayTime ? this.props.searchDelayTime : 0;
161-
this.handleDebounce(() => {
162-
this.props.onSearch(this.refs.seachInput.value);
163-
},
164-
delay
165-
)();
168+
handleKeyUp = (event) => {
169+
event.persist();
170+
this.debounceCallback(event);
166171
}
167172

168173
handleExportCSV = () => {

0 commit comments

Comments
 (0)