I have created a custom dropdown menu in Javascript React using the react-select
component. By using the optionComponent
prop I was able to render each option with a checkbox (see image). My problem is now that once you click any checkbox the select options close which is not a very good user experience.
Image:
Therefore my question is if there is any way of preventing the drop-down from closing until the user clicks the arrow in the right-hand side of the select to make it possible to tick and untick any number of check boxes before closing down the options.
You could stopPropagation of the click event from the checkbox element.
Let's assume this is your checkbox click handler:
This way, when the checkbox is clicked, it will not trigger the select handler on the dropdown.