react-multi-select-component icon indicating copy to clipboard operation
react-multi-select-component copied to clipboard

Unable to close the dropdown after double selection

Open Uni2K opened this issue 1 year ago • 5 comments

Describe the bug When using a custom ItemRenderer, double selecting a single item will remove the capability to close the dropdown when clicking outside.

Sandbox / Git Repo https://codesandbox.io/s/naughty-dewdney-wn7v74?file=/src/App.js

To Reproduce Steps to reproduce the behavior:

  1. Check out the repo
  2. Select a single item
  3. Deselect the item
  4. click outside of the dropdown
  5. It won't close

Expected behavior It closes when clicked outside

Screenshots closing

Desktop (please complete the following information):

  • OS: Win 11
  • Chrome
  • Latest

Additional context Maybe I use the Default Item renderer wrong, but there is no working example in the docs and this was the only thing I found in the soruce code.

Uni2K avatar Jul 27 '23 08:07 Uni2K

Hi, I have the same issue. Any update on this one?

PhucNguyenHDW avatar Nov 23 '23 02:11 PhucNguyenHDW

Checkout this : https://codesandbox.io/p/sandbox/react-multi-select-example-uqtgs?file=%2Fsrc%2FApp.js%3A1%2C1-34%2C1

Souravvmishra avatar Feb 07 '24 17:02 Souravvmishra

Hi @Souravvmishra If we use the default list, it will work as expected. Bug case is When using a custom ItemRenderer

PhucNguyenHDW avatar Feb 15 '24 08:02 PhucNguyenHDW

I work around this by using the useClickAway hook in @uidotdev/usehooks Put the MultiSelect component in div with ref from useClickAway When clicked outside, trigger function to find to class .dropdown-heading, then trigger click event. Worked!

PhucNguyenHDW avatar Feb 15 '24 08:02 PhucNguyenHDW

@Uni2K Please check the focus of the dropdown. When you use a ItemRender after first click, the Dropdown loses focus and cannot be closed clicking outside.

gauthamdas avatar May 02 '24 04:05 gauthamdas