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

希望Popconfirm组件支持一个disabled的属性 #16947

Closed
1 task
lhyt opened this issue Jun 4, 2019 · 4 comments
Closed
1 task

希望Popconfirm组件支持一个disabled的属性 #16947

lhyt opened this issue Jun 4, 2019 · 4 comments
Labels

Comments

@lhyt
Copy link
Contributor

lhyt commented Jun 4, 2019

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

What problem does this feature solve?

包住有可能disabled的Button的时候,如果按钮是disabled,点击还会弹出确认框:

<Popconfirm
  onConfirm={this.handleConf}
  title="title"
  okText="确定"
  cancelText="取消"
>
  <Button type="danger" icon="delete" loading={deleteing} disabled={isDisabled}>
    删除
  </Button>
</Popconfirm>

这样子,就要加个判断,按照条件去掉外面那层Popconfirm,有点麻烦:

{!isDisabled? (
  <Popconfirm
    onConfirm={this.handleConf}
    title="title"
    okText="确定"
    cancelText="取消"
  >
    <Button type="danger" icon="delete" loading={deleteing}>
      删除
    </Button>
  </Popconfirm>
) : (
  <Button type="danger" icon="delete" disabled>
    删除
  </Button>
)}

如果用的是visible={!isDisabled}来控制,那么此时如果不是disabled,不用点都会弹出了,这样子又要额外写state控制,也是麻烦。

所以希望有一个disabled属性,可以少写这些逻辑

What does the proposed API look like?

支持disabled属性,使得点击都不会弹出确认框,最好能透传,连button都不用写disabled了

<Popconfirm
  onConfirm={this.handleConf}
  title="title"
  okText="确定"
  cancelText="取消"
  disabled={isDisabled}
>
  <Button type="danger" icon="delete" loading={deleteing} disabled={isDisabled}>
    删除
  </Button>
</Popconfirm>
@afc163
Copy link
Member

afc163 commented Jun 4, 2019

可以来个 PR~

最好能透传,连button都不用写disabled了

透传没必要,做的太多了。

@zombieJ
Copy link
Member

zombieJ commented Jun 4, 2019

@lhyt
Copy link
Contributor Author

lhyt commented Jun 4, 2019

这样? https://codesandbox.io/s/youthful-bogdan-s6ld8

就是这个效果

@afc163
Copy link
Member

afc163 commented Jul 22, 2019

#16985

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

No branches or pull requests

5 participants