简体   繁体   English

Select 在 Chakra-UI 中与 Radio 结合使用时不起作用

[英]Select does not work when combined with Radio in Chakra-UI

I have a design where I need to combine radio group and select items together.我有一个设计,我需要将无线电组和 select 项组合在一起。 Specifically, when a user select an option, then need to select an item from the list.具体来说,当用户 select 一个选项时,则需要 select 从列表中选择一个项目。

My implementation at https://codesandbox.io/s/chakra-radio-select-cv6r0?file=/src/index.tsx shows how it should look.我在https://codesandbox.io/s/chakra-radio-select-cv6r0?file=/src/index.tsx的实现显示了它的外观。

However, when I click on the list to select from drop down, nothing happens.但是,当我从下拉列表中单击列表到 select 时,没有任何反应。

The select works independently, but not when nested inside RadioGroup. select 独立工作,但嵌套在 RadioGroup 中时不工作。 This is reproducible on codesandbox这在codesandbox上是可重现的

Could someone help me understand what is incorrect here and what I need to do to be able to select the item from the list?有人可以帮助我了解这里有什么不正确的地方,以及我需要做什么才能从列表中找到 select 项目吗?

Thanks谢谢

Just move the Select input outside of the Radio component like this像这样将Select输入移到Radio组件之外

<Flex alignItems={"center"}>
  <Radio value={"LIST"}>
    <Text ml={2}>List</Text>
  </Radio>
  <Select
    w="unset"
    ml={4}
    placeholder="Select List"
    onChange={() => console.log("change")}
    value={"option 1"}
  >
    <option value="option1">Option 1</option>
    <option value="option2">Option 2</option>
    <option value="option3">Option 3</option>
  </Select>
</Flex>

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

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