jakezatecky / react-dual-listbox

A feature-rich dual listbox for React.
https://jakezatecky.github.io/react-dual-listbox/
MIT License
110 stars 59 forks source link

Restrict available options but allow duplicates? #110

Closed singh87 closed 4 years ago

singh87 commented 4 years ago

I am running into an issue where I need to restrict the available options but also allow duplicates in the selected list. I thought I was doing something wrong at first but then I looked into the code and saw that these two options are not allowed to coexist. I'm just trying to figure out why this is and how easy would it be to allow both options


if (allowDuplicates) {
            // If we allow duplicates, all options will always be available
            filterer = () => true;
        } else if (available !== undefined) {
            // If the caller is restricting the available options, combine that with the default
            filterer = (option) => (
                this.getFlatOptions(available).indexOf(option.value) >= 0 &&
                this.getFlatOptions(selected).indexOf(option.value) < 0
            );
        }```
jakezatecky commented 4 years ago

Thanks for the bug report. That is not the intention!