tbleckert / react-select-search

⚡️ Lightweight select component for React
https://react-select-search.com
MIT License
676 stars 149 forks source link

select-search scroll isn't clickable #113

Closed DianaNOSE closed 3 years ago

DianaNOSE commented 3 years ago

anytime i make a click in the select-search scroll it closes, making it troubling for the user, but you can scoll with the wheel so it is actually working in some way, is there any solution to it?

in a file of useSelect.js in the onBlur callback i got a condition with a document.getElementById to know if it makes focus on the container or not, depending on the condition i update the focus from true to false and backwards, and even if it is a temporary solution, if i use more than 1 select it stops working.

this is the full code im using for this:

const onBlur = useCallback(() => {
        window.addEventListener('click', function(e){   
            if (document.getElementById('selectSearchDebit').contains(e.target)){
              //console.log("clic dentro del Debit")
            } else{
                setState((oldState) => ({
                    ...oldState,
                    focus: false,
                    search: '',
                    flat: flatDefaultOptions,
                    highlighted: -1,
                }));
              //console.log("clic fuera del Debit")
            }});

            window.addEventListener('click', function(e){   
              if (document.getElementById('selectSearchCredit').contains(e.target)){
                //console.log("clic dentro del Credit")
              } else{
                setState((oldState) => ({
                    ...oldState,
                    focus: false,
                    search: '',
                    flat: flatDefaultOptions,
                    highlighted: -1,
                }));
                //console.log("clic fuera del Credit")
              }
            });
tbleckert commented 3 years ago

Thanks for the debugging and reporting. I'll look into some options to make the focus/blur handling a bit more bulletproof.

tbleckert commented 3 years ago

Fixed in v2.2.3