Merge pull request #18138 from laysent/master

fix: tooltip not work with disabled checkbox
This commit is contained in:
偏右 2019-08-07 14:55:51 +08:00 committed by GitHub
commit 81cf7bd520
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 1 deletions

View File

@ -46,6 +46,8 @@ export interface CheckboxChangeEvent {
class Checkbox extends React.Component<CheckboxProps, {}> {
static Group: typeof CheckboxGroup;
static __ANT_CHECKBOX = true;
static defaultProps = {
indeterminate: false,
};

View File

@ -13,6 +13,31 @@ exports[`Tooltip should hide when mouse leave antd disabled component Button 1`]
</span>
`;
exports[`Tooltip should hide when mouse leave antd disabled component Checkbox 1`] = `
<span
style="display: inline-block; cursor: not-allowed;"
>
<label
class="ant-checkbox-wrapper ant-checkbox-wrapper-disabled"
style="pointer-events: none;"
>
<span
class="ant-checkbox ant-checkbox-disabled"
>
<input
class="ant-checkbox-input"
disabled=""
type="checkbox"
value=""
/>
<span
class="ant-checkbox-inner"
/>
</span>
</label>
</span>
`;
exports[`Tooltip should hide when mouse leave antd disabled component Switch 1`] = `
<span
style="display: inline-block; cursor: not-allowed;"

View File

@ -3,6 +3,7 @@ import { mount } from 'enzyme';
import Tooltip from '..';
import Button from '../../button';
import Switch from '../../switch';
import Checkbox from '../../checkbox';
import DatePicker from '../../date-picker';
import Input from '../../input';
import Group from '../../input/Group';
@ -107,6 +108,7 @@ describe('Tooltip', () => {
testComponent('Button', Button);
testComponent('Switch', Switch);
testComponent('Checkbox', Checkbox);
});
it('should render disabled Button style properly', () => {

View File

@ -87,7 +87,10 @@ const splitObject = (obj: any, keys: string[]) => {
function getDisabledCompatibleChildren(element: React.ReactElement<any>) {
const elementType = element.type as any;
if (
(elementType.__ANT_BUTTON || elementType.__ANT_SWITCH || element.type === 'button') &&
(elementType.__ANT_BUTTON ||
elementType.__ANT_SWITCH ||
elementType.__ANT_CHECKBOX ||
element.type === 'button') &&
element.props.disabled
) {
// Pick some layout related style properties up to span