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

Using Asyc with minimunInput > 0, all selected items get removed from the text area when you clear the search inputValue. #1220

Closed
yanmaoyuan opened this issue Sep 14, 2016 · 3 comments

Comments

@yanmaoyuan
Copy link

Thanks for using react-select!

If you are reporting an error please include a test case that demonstrates the issue you're reporting!
This is very helpful to maintainers in order to help us see the issue you're seeing.

Here is a Plunker you can fork that has react-select loaded and supports JSX syntax:
https://plnkr.co/edit/HTmtER9AMNcPoWhXV707?p=preview

You may also find the online Babel tool quite helpful if you wish to use ES6/ES7 syntax not yet supported by the browser you are using.

@yanmaoyuan
Copy link
Author

yanmaoyuan commented Sep 14, 2016

Steps to reproduce:

  1. Use Asyc fetching options
  2. set minimum input to 2 (anything greater than 0 will do)
  3. enter some input value into the search box, and select a few items from the dropdown
  4. backspace to remove your search input value

expected: the selected items remains
actual: the selected items are removed as soon as inputValue.length < minimumInput

@bvaughn
Copy link
Collaborator

bvaughn commented Sep 18, 2016

FYI I am working on a refactor for Async that will invalidate this issue. (See PR #1226)

I plan to deprecate the minimunInput property. I believe it causes more complication than it's worth and is better handled by application logic. For example, you can enforce a similar behavior in a more customizable way in your application code like so:

let previousLoadPromise

function loadOptions (inputValue) {
  if (inputValue && inputValue.length > 2) {
    previousLoadPromise = fetch(...) // load new options based on inputValue
} ellse if (!previouslyLoadedOptions) {
    previousLoadPromise = fetch(...) // load initial / default options
  }

  // else return the previously-loaded options
  // this way, input text that's shorter than 2 chars won't reset options
  // if you wanted to reset options in this case, you could by adding an else:
  // previousLoadPromise = Promise.resolve()

  return previousLoadPromise
}

@bvaughn
Copy link
Collaborator

bvaughn commented Sep 18, 2016

Resolved via PR #1226.

Look for an RC2 to come out (hopefully) sometime today with this change.

@bvaughn bvaughn closed this as completed Sep 18, 2016
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