Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.0放在Dropdown里的Popconfirm无法正常生效 #22007

Closed
1 task
MangGoDio opened this issue Mar 9, 2020 · 7 comments
Closed
1 task

4.0放在Dropdown里的Popconfirm无法正常生效 #22007

MangGoDio opened this issue Mar 9, 2020 · 7 comments

Comments

@MangGoDio
Copy link

  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

Edit on CodeSandbox

Steps to reproduce

点击操作 -> 删除

What is expected?

弹出确认删除的弹框,点击确认

What is actually happening?

弹框秒消失

Environment Info
antd 4.0.1
React 16.8.6
System windows 10
Browser 79.0
@afc163 afc163 closed this as completed Mar 9, 2020
@MangGoDio
Copy link
Author

https://ant.design/docs/react/faq-cn#%E5%BD%93%E6%88%91%E7%82%B9%E5%87%BB-Select-Dropdown-DatePicker-TimePicker-Popover-Popconfirm-%E5%86%85%E7%9A%84%E5%8F%A6%E4%B8%80%E4%B8%AA-popup-%E7%BB%84%E4%BB%B6%E6%97%B6%E5%AE%83%E4%BC%9A%E6%B6%88%E5%A4%B1%EF%BC%8C%E5%A6%82%E4%BD%95%E8%A7%A3%E5%86%B3%EF%BC%9F

#3487 #3438

我看FAQ的说明是:
该问题在 3.11.0 后已经解决。如果你仍在使用旧版本,你可以通过 <Select getPopupContainer={trigger => trigger.parentNode}> 来在 Popover 中渲染组件

我看了下线上的antd版本是3.20.0,测试环境是4.0.1
3.20.0的dropdown里点击了menu.item,dropdown被关闭,但是Popconfirm还是存在
4.0.1的dropdown里点击了menu.item,dropdown被关闭,但是Popconfirm跟着一起被关闭了,
试了下getPopupContainer并没有解决这个问题,还是说只能手动控制dropdown的visible来解决呢?

@afc163 afc163 reopened this Mar 9, 2020
@afc163
Copy link
Member

afc163 commented Mar 9, 2020

看了一下你的场景不太一样。点击 Menu.Item 默认都会触发 Dropdown 关闭。

你可以用阻止冒泡取消这个行为:https://codesandbox.io/s/antd-reproduction-template-yhzh6

或者按你说的,参照 https://ant.design/components/dropdown-cn/#components-dropdown-demo-overlay-visible 手动控制 Dropdown 的 visible

@afc163 afc163 closed this as completed Mar 9, 2020
@MangGoDio
Copy link
Author

好的,非常感谢!

@allenpzx
Copy link

allenpzx commented Sep 1, 2020

看了一下你的场景不太一样。点击 Menu.Item 默认都会触发 Dropdown 关闭。

你可以用阻止冒泡取消这个行为:https://codesandbox.io/s/antd-reproduction-template-yhzh6

或者按你说的,参照 https://ant.design/components/dropdown-cn/#components-dropdown-demo-overlay-visible 手动控制 Dropdown 的 visible

请问typescript的话,onClick的props没在定义上,如何覆盖组件的props呢

@xoptimal
Copy link

xoptimal commented Dec 1, 2020

@afc163 如果 Dropdown 下有操作呢, 比如有一个 Input, 我在 onClick => event.stopPropagation() , 但是自身的 onChange 将无效了, 请问该怎么搞

 <Menu.Item key={'custom'}>
        <Input
          value={contactValue}
          onClick={event => event.stopPropagation()}
          onChange={event => setContactValue(event.target.value)}
          onPressEnter={(event) => {
            const findIndex = contactList.findIndex(item => item === contactValue)
            if (findIndex === -1) {
              setContactList(prevState => ([...prevState, contactValue]))
              setContactValue("")
            }
          }}
          size="small"/>
      </Menu.Item>

@cxiiiiiii
Copy link

看了一下你的场景不太一样。点击 Menu.Item 默认都会触发 Dropdown 关闭。
你可以用阻止冒泡取消这个行为:https://codesandbox.io/s/antd-reproduction-template-yhzh6
或者按你说的,参照 https://ant.design/components/dropdown-cn/#components-dropdown-demo-overlay-visible 手动控制 Dropdown 的 visible

请问typescript的话,onClick的props没在定义上,如何覆盖组件的props呢

请问你解决了吗,我遇到跟你一样的问题,antd 3.20.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants