Skip to content

Commit

Permalink
Merge pull request #364 from madeinfree/delay-search-issue
Browse files Browse the repository at this point in the history
urgent to fixed the delay search bug.
  • Loading branch information
AllenFang committed Mar 28, 2016
2 parents 0928909 + 6df046d commit d601337
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/js/manipulation/debounce-search-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ addProducts(5);
export default class DebounceSearchTable extends React.Component {
render() {
const options = {
searchDelayTime: 500
searchDelayTime: 3000
};

return (
Expand Down
19 changes: 12 additions & 7 deletions src/toolbar/ToolBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ class ToolBar extends Component {
};
}

componentWillMount() {
const delay = this.props.searchDelayTime ? this.props.searchDelayTime : 0;
this.debounceCallback = this.handleDebounce(() => {
this.props.onSearch(this.refs.seachInput.value);
},
delay
);
}

componentWillUnmount() {
this.clearTimeout();
}
Expand Down Expand Up @@ -156,13 +165,9 @@ class ToolBar extends Component {
};
}

handleKeyUp = () => {
const delay = this.props.searchDelayTime ? this.props.searchDelayTime : 0;
this.handleDebounce(() => {
this.props.onSearch(this.refs.seachInput.value);
},
delay
)();
handleKeyUp = (event) => {
event.persist();
this.debounceCallback(event);
}

handleExportCSV = () => {
Expand Down

0 comments on commit d601337

Please sign in to comment.