简体   繁体   English

如何让 Combobox onSelect 在 React Bootstrap 模态上工作?

[英]How do I get Combobox onSelect to work on React Bootstrap modal?

I have a React Bootstrap Modal in which is a Reach UI Combobox.我有一个 React Bootstrap Modal,其中有一个 Reach UI Combobox。 The issue is, I can select the items from the Combobox when they are on the page but not in the Modal on left mouse click (it works with using the down arrow and hitting enter to select).问题是,当项目在页面上时,我可以从组合框中选择项目,但在鼠标左键单击时不能在模态中选择(它与使用向下箭头并按回车键进行选择一起使用)。 The onSelect doesn't get triggered when in the modal. onSelect在模态中不会被触发。

I have a code sandbox at https://codesandbox.io/s/staging-butterfly-42fo2?file=/src/App.js where the issue is reproduced.我在https://codesandbox.io/s/staging-butterfly-42fo2?file=/src/App.js有一个代码沙箱,问题在其中重现。

What's the issue and how do I get the click to work?问题是什么?如何让点击正常工作?

I found that playing with your code and setting https://reach.tech/combobox#comboboxpopover-portalto false works for me.我发现使用您的代码并设置https://reach.tech/combobox#comboboxpopover-portalto false 对我有用。

Give it a try.试试看。

glhf高能

Set the 'portal-props' of the ComboboxPopover to be 'false' will work:将 ComboboxPopover 的 'portal-props' 设置为 'false' 将起作用:

<ComboboxPopover portal={false}>...</ComboboxPopover>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM