💄 should not insert space to link button

close #18118
This commit is contained in:
afc163 2019-09-07 19:42:04 +08:00 committed by 偏右
parent cf97324abd
commit c2bcf44f62
3 changed files with 19 additions and 2 deletions

View File

@ -222,6 +222,17 @@ exports[`Button should merge text if children using variable 1`] = `
</button>
`;
exports[`Button should not insert space to link button 1`] = `
<button
class="ant-btn ant-btn-link"
type="button"
>
<span>
按钮
</span>
</button>
`;
exports[`Button should not render as link button when href is undefined 1`] = `
<button
class="ant-btn ant-btn-primary"

View File

@ -70,6 +70,12 @@ describe('Button', () => {
expect(wrapper.find('.ant-btn').hasClass('ant-btn-two-chinese-chars')).toBe(true);
});
// https://github.com/ant-design/ant-design/issues/18118
it('should not insert space to link button', () => {
const wrapper = render(<Button type="link">按钮</Button>);
expect(wrapper).toMatchSnapshot();
});
it('have static property for type detecting', () => {
const wrapper = mount(<Button>Button Text</Button>);
// eslint-disable-next-line

View File

@ -217,8 +217,8 @@ class Button extends React.Component<ButtonProps, ButtonState> {
}
isNeedInserted() {
const { icon, children } = this.props;
return React.Children.count(children) === 1 && !icon;
const { icon, children, type } = this.props;
return React.Children.count(children) === 1 && !icon && type !== 'link';
}
renderButton = ({ getPrefixCls, autoInsertSpaceInButton }: ConfigConsumerProps) => {