Skip to content

Commit

Permalink
Add 'query' param, which is the text string entered by the user, to t…
Browse files Browse the repository at this point in the history
…he onSearch function. Might be usefull with filtering on heavy requests.
  • Loading branch information
Ron-Lavi committed Apr 12, 2018
1 parent 64be3a2 commit a92d296
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/components/AutoComplete/AsyncAutoComplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ class AsyncAutoComplete extends React.Component {

onSearchEnd = options => this.setState({ options, isLoading: false });

handleSearch = () => {
// query is the text string entered by the user.
handleSearch = query => {
this.onSearchStart();
Promise.resolve(this.props.onSearch()).then(options =>
Promise.resolve(this.props.onSearch(query)).then(options =>
this.onSearchEnd(options)
);
};
Expand Down
3 changes: 2 additions & 1 deletion src/components/AutoComplete/AutoComplete.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ AutoCompleteStories.addWithInfo('Use With Forms', () => {
});

AutoCompleteStories.addWithInfo('Using Async Calls', () => {
const handleSearch = () =>
// query is the text string entered by the user.
const handleSearch = query =>
fetch('https://api.github.com/repos/patternfly/patternfly-react/forks')
.then(response => response.json())
.then(forks => forks.map(fork => fork.owner));
Expand Down

0 comments on commit a92d296

Please sign in to comment.