问题
I'm using a fork of React-Select for a project adding customized functionality. I'm trying to disable the dropdown from opening when a user clicks on one of the tags (When multi is set to true). So if a user clicks on one of the tags the dropdown menu won't open. I went over Value.js file to see if I could find the isOpen state triggered by clicking on the tags but couldn't find it.
Here's a screenshot illustrating what I mean.
回答1:
In case if used custom tag component (valueComponent
)
try to use:
onMouseDown = (e) => e.stopPropagation();
(instead of onClick
) on that component.
来源:https://stackoverflow.com/questions/49159086/react-select-onclick-on-multi-tag-prevent-open-dropdown