React-Select onClick 多标签防止打开下拉菜单 [英] React-Select onClick on multi tag prevent open dropdown

查看:98
本文介绍了React-Select onClick 多标签防止打开下拉菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 React-Select 的一个分支来添加自定义功能的项目.当用户单击其中一个标签时(当 multi 设置为 true 时),我试图禁止下拉菜单打开.因此,如果用户单击其中一个标签,下拉菜单将不会打开.我查看了 Value.js 文件,看看是否可以找到通过点击标签触发的 isOpen 状态,但找不到.

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.

推荐答案

如果使用自定义标签组件 (valueComponent)尝试使用:

In case if used custom tag component (valueComponent) try to use:

onMouseDown = (e) =>e.stopPropagation();

(而不是 onClick)在该组件上.

(instead of onClick) on that component.

这篇关于React-Select onClick 多标签防止打开下拉菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆