Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Every backspace Removes call load option method. #83

Closed
ravishah990 opened this issue Jul 6, 2017 · 1 comment
Closed

Every backspace Removes call load option method. #83

ravishah990 opened this issue Jul 6, 2017 · 1 comment

Comments

@ravishah990
Copy link

ravishah990 commented Jul 6, 2017

How to call every backspace remove call load option. I am using select.Async control in every input change method call fetch method and fetch data but when I press backspace then first time called that load option method but in next time that can't call load option method.

` <Select.Async
onChange={this.onChange}
valueKey="placeID"
filterOptions={this.filterOptions}
labelKey="cityState"
loadOptions={this.getUsers}
onInputChange={inp => this.onInputChange(inp)}
onBlur={this.onBlur}
onInputKeyDown={inp => this.onInputKeyDown(inp)}
onFocus={this.onFocousSearch}
value={this.state.value}
searchPromptText="Please enter 3 or more characters"
loadingPlaceholder={this.state.loadingtext}
noResultsText="No results found"
options={this.state.options}
placeholder={this.state.placeholdervalue}
autoBlur

/> `

In above code in load option that get user method call. My get User method is :
`
getUsers = (input) => {
console.log(input);
if (!input) {
return Promise.resolve({ options: [] });
}
if (input.length > 2) {
const newstate = this.state;
newstate.loadingtext = 'Searching...';
this.setState({ newstate });
const searchLocation = Object.assign({}, cookie.load('cLocation'));
searchLocation.searchText = input;
searchLocation.isBusiness = false;
console.log(input.toString().length);
return fetch(sourceName.searchNavbar, apiUrl.locationAndBusiness,
searchLocation)
.then(json => ({ options: json.data }));
}
return null;
}

`

When I click first time back space then get user method call but in second time I pressed back space then not called that get user method. How to call every backspace remove call this method.

@TrevorBurnham
Copy link
Contributor

I'm having a hard time understanding your question. loadOptions is called every time onInputChange is called (unless onInputChange throws an error), as you can see here:

_onInputChange (inputValue) {
const { ignoreAccents, ignoreCase, onInputChange } = this.props;
if (ignoreAccents) {
inputValue = stripDiacritics(inputValue);
}
if (ignoreCase) {
inputValue = inputValue.toLowerCase();
}
if (onInputChange) {
onInputChange(inputValue);
}
return this.loadOptions(inputValue);
}

I hope you can find the answers you want in that source file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants