react-select-search icon indicating copy to clipboard operation
react-select-search copied to clipboard

After Search, selection of results doesnt work show the chosen items

Open no-1ne opened this issue 4 years ago • 8 comments

Describe the bug https://react-select-search.com/?path=/story/single-select--search if we search for something and select the results, it doesnt reflect the chosen option

To Reproduce Steps to reproduce the behavior:

  1. Go to https://react-select-search.com/?path=/story/single-select--search
  2. Search for anything
  3. Pick an item in the filtered results
  4. See error

Expected behavior it should show selected option

Screenshots image

Desktop (please complete the following information): Chrome 94 Desktop(chromeOS)

no-1ne avatar Dec 06 '21 01:12 no-1ne

I solved this using if (document.activeElement) { (document.activeElement as HTMLElement).blur(); }

AdamElhawary avatar Jan 05 '22 12:01 AdamElhawary

I have experienced the same bug.

otienog1 avatar Jan 14 '22 09:01 otienog1

Same bug for me. Downgraded to 2.x version

mmv93 avatar Jan 14 '22 09:01 mmv93

I have the same issue

dolby360 avatar Feb 03 '22 21:02 dolby360

I solved this using if (document.activeElement) { (document.activeElement as HTMLElement).blur(); }

I'm not sure how it should work on react

dolby360 avatar Feb 03 '22 21:02 dolby360

I have experienced the same bug.

charles-aguiar avatar Feb 24 '22 11:02 charles-aguiar

What worked for me is to store the value on a state, and pass a setter to the "onChange" property. Note that this is not done at https://react-select-search.com/?path=/story/single-select--search.

`export const Search = () => { const [selected, setSelected] = useState(null);

console.log({ selected });

return (
    <SelectSearch
        options={countries}
        search
        filterOptions={fuzzySearch}
        placeholder="Select your country"
        value={selected}
        onChange={setSelected}
    />
)

};`

charles-aguiar avatar Feb 24 '22 12:02 charles-aguiar

I've also got the same bug. onChange doesn't seem to return any value so I can't store the value in state as a workaround.

After a bit of digging, I think this might relate to the Fuse.js version. Originally I had "fuse.js": "^6.5.3" but it seems this library uses "fuse.js": "3.4.5". I had written fuzzySearch exactly like the one in this library (but with a different threshold) but it wasn't working, downgrading fuse.js in my project seemed to fix it.

Gr1mdrag0n avatar Mar 22 '22 20:03 Gr1mdrag0n