简体   繁体   English

提交选中的 Atlaskit Dropdown(@atlaskit/dropdown-menu) 菜单复选框,点击项目

[英]Submit checked Atlaskit Dropdown(@atlaskit/dropdown-menu) menu checkboxes on Item click

I am using @atlaskit/dropdown-menu ( https://atlaskit.atlassian.com/packages/core/dropdown-menu ).我正在使用@atlaskit/dropdown-menu ( https://atlaskit.atlassian.com/packages/core/dropdown-menu )。 I would like to submit a small form on Item click, I need to submit values of DropdownItemCheckbox .我想在Item单击时提交一个小表单,我需要提交DropdownItemCheckbox值。

Here is a code to render needed components: https://codesandbox.io/s/py8qoo64mq这是渲染所需组件的代码: https : //codesandbox.io/s/py8qoo64mq

import React from "react";
import Dropdown, {
  DropdownItemCheckbox,
  DropdownItemGroupCheckbox,
  DropdownItem
} from "@atlaskit/dropdown-menu";

export default () => (
  <Dropdown defaultOpen triggerType="button" trigger="Drop menu">
    <DropdownItemGroupCheckbox id="languages2" title="Languages">
      <DropdownItemCheckbox defaultSelected id="js-check">
        JavaScript
      </DropdownItemCheckbox>
      <DropdownItemCheckbox id="java">Java</DropdownItemCheckbox>
      <DropdownItemCheckbox defaultSelected id="ruby">
        Ruby
      </DropdownItemCheckbox>
    </DropdownItemGroupCheckbox>
    <DropdownItem>Submit</DropdownItem>
  </Dropdown>
);

I don't want to use Select because I want to trigger dropdown list with a custom button, and use layering advantages of DropdownMenu我不想使用Select因为我想用自定义按钮触发下拉列表,并使用 DropdownMenu 的分层优势

I had the same issue, and after a lot of research i found that the problem was caused by styled-components package, but it works with if the version is <=3.5.0-0.我遇到了同样的问题,经过大量研究,我发现问题是由 styled-components 包引起的,但如果版本 <=3.5.0-0,它可以工作。 So my solution was to downgrade styled-components package to 3.5.0-0.所以我的解决方案是将 styled-components 包降级到 3.5.0-0。 This does not explain why it doesn't work because they are just styles.这并不能解释为什么它不起作用,因为它们只是样式。 But for now this is a workaround.但目前这是一种解决方法。

After i raised an issue, Atlassian sent me the following response that i think will answer your questions.在我提出问题后,Atlassian 向我发送了以下回复,我认为这些回复可以回答您的问题。

Atlaskit doesn't officially support styled-components v4 and above. Atlaskit 不正式支持 styled-components v4 及更高版本。 We currently require that our consumers use SC v3.2.6 as per our peer dependency.我们目前要求我们的消费者根据我们的对等依赖使用 SC v3.2.6。 However, recently there has been some ongoing work to upgrade / migrate Atlaskit to a more modern css-in-js library and we're working through the decision making process internally at the moment.但是,最近有一些正在进行的工作将 Atlaskit 升级/迁移到更现代的 css-in-js 库,目前我们正在内部完成决策过程。 Please feel free to follow this ticket for status updates: https://ecosystem.atlassian.net/browse/DS-6836请随时关注此票以获取状态更新: https : //ecosystem.atlassian.net/browse/DS-6836

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

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