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

search always returns empty list #19

Closed
kmclaugh opened this issue Jun 7, 2021 · 0 comments
Closed

search always returns empty list #19

kmclaugh opened this issue Jun 7, 2021 · 0 comments

Comments

@kmclaugh
Copy link

kmclaugh commented Jun 7, 2021

I have everything working with use-select except the search.

When I use the setSearch function like so:

<input
    type="text"
    name="search"
    autoComplete="off"
    onChange={(e) => {
      setSearch(e.target.value);
    }}
    className="focus:ring-indigo-500 focus:border-indigo-500 block w-full pl-9 sm:text-sm border-gray-300 rounded-md"
    placeholder="Search"
  />

visibleOptions always returns an empty array, no matter what I search for.

Also I try to override the filterFn like so:

  const searchFilter = (options, searchValue) => {
    console.log(options, searchValue);
    return options;
  };
const {
    visibleOptions,
    selectedOption,
    getInputProps,
    getOptionProps,
    isOpen,
    setOpen,
    setSearch,
    searchValue,
  } = useSelect({
    multi: true,
    options,
    value,
    onChange,
    optionsRef,
    filterFn: (options, searchValue) => searchFilter(options, searchValue),
  });

the searchFilter function is never called (it never logs anything).

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