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

Checkbox.Group 和 Radio.Group 的 disabled 机制不一样,应该 group 的 disabled 禁用优先级更高,checkbox 是错的 #7266

Closed
reoszo opened this issue Aug 19, 2017 · 14 comments
Labels
help wanted The suggestion or request has been accepted, we need you to help us by sending a pull request.

Comments

@reoszo
Copy link

reoszo commented Aug 19, 2017

Version

2.12.6

Environment

all

Reproduction link

https://codepen.io/benjycui/pen/KgPZrE?editors=001

Steps to reproduce

Radio 源码:radioProps.disabled = props.disabled || radioGroup.disabled;
Checkbox 源码:checkboxProps.disabled = 'disabled' in props ? props.disabled : checkboxGroup.disabled;

What is expected?

Checkbox.Group disable 时,所有 Checkbox disable。

What is actually happening?

Checkbox 根据自己的 disabled 属性显示禁用状态

@ant-design-bot
Copy link
Contributor

It will be better to write your issue/comment in English, so more people can understand you.
And this means that more people can help you or benefit from your issue/comment.
See: #4897

@benjycui
Copy link
Contributor

按我的理解,应该是 Checkbox 的才是对的,就像 CSS 样式那样,直接加到元素本身的样式,优先级在继承过来的之上。

@benjycui benjycui added the help wanted The suggestion or request has been accepted, we need you to help us by sending a pull request. label Aug 21, 2017
@benjycui
Copy link
Contributor

@reoszo 来个 PR?

@reoszo
Copy link
Author

reoszo commented Aug 21, 2017

你按照的是研发的代码角度看的,要是考虑使用上来说,组都disable了,单项还能用?

@afc163
Copy link
Member

afc163 commented Aug 21, 2017

从任何角度来说 Checkbox 的属性优先都是更合理的。RadioGroup 的实现有问题。

@reoszo
Copy link
Author

reoszo commented Aug 21, 2017

你确定?业务中使用人员的情况了解一下吧

@reoszo
Copy link
Author

reoszo commented Aug 21, 2017

要是Checkbox是对的,我就不pr了,我自己改我们的Checkbox了,[哭笑]

@afc163
Copy link
Member

afc163 commented Aug 21, 2017

不急,我先找找其他 UI 库的做法。

@afc163
Copy link
Member

afc163 commented Aug 21, 2017

按我的理解,应该是 Checkbox 的才是对的,就像 CSS 样式那样,直接加到元素本身的样式,优先级在继承过来的之上。

我理解 @reoszo 的思路了,disabled 不是从 Group 上继承过来的属性。而是 Group 本身的属性。表现为和 Checkbox/Radio 自身属性的『或』叠加,只要有一个 disabled 就应该 disabled。

所以 @reoszo 应该是对的,来个 PR 吧。最好补上用例。

@reoszo
Copy link
Author

reoszo commented Aug 21, 2017

@reoszo
Copy link
Author

reoszo commented Aug 21, 2017

就一行代码啊,你们顺手改了吧,呵呵

@afc163
Copy link
Member

afc163 commented Aug 21, 2017

贡献一下,后面说不定还有 bug。

@reoszo
Copy link
Author

reoszo commented Aug 21, 2017

好,我试一把先

@afc163
Copy link
Member

afc163 commented Aug 24, 2017

Thx! @dilidili

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted The suggestion or request has been accepted, we need you to help us by sending a pull request.
Projects
None yet
Development

No branches or pull requests

4 participants