Browse Source

fix: duplicated className on Search[allowClear] (#27261)

* fix: duplicated className on Search[allowClear]

close #27258

* fix snapshot
pull/27265/head
偏右 4 years ago
committed by GitHub
parent
commit
27e9926438
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      components/form/__tests__/__snapshots__/demo.test.js.snap
  2. 10
      components/input/ClearableLabeledInput.tsx
  3. 7
      components/input/__tests__/Search.test.js

2
components/form/__tests__/__snapshots__/demo.test.js.snap

@ -7622,7 +7622,7 @@ exports[`renders ./components/form/demo/validate-static.md correctly 1`] = `
class="ant-form-item-control-input-content"
>
<span
class="ant-input-affix-wrapper ant-input-password"
class="ant-input-affix-wrapper"
>
<input
action="click"

10
components/input/ClearableLabeledInput.tsx

@ -112,9 +112,7 @@ class ClearableLabeledInput extends React.Component<ClearableInputProps> {
const prefixNode = prefix ? <span className={`${prefixCls}-prefix`}>{prefix}</span> : null;
const affixWrapperCls = classNames(
`${prefixCls}-affix-wrapper`,
{
const affixWrapperCls = classNames(`${prefixCls}-affix-wrapper`, {
[`${prefixCls}-affix-wrapper-focused`]: focused,
[`${prefixCls}-affix-wrapper-disabled`]: disabled,
[`${prefixCls}-affix-wrapper-sm`]: size === 'small',
@ -123,9 +121,9 @@ class ClearableLabeledInput extends React.Component<ClearableInputProps> {
[`${prefixCls}-affix-wrapper-rtl`]: direction === 'rtl',
[`${prefixCls}-affix-wrapper-readonly`]: readOnly,
[`${prefixCls}-affix-wrapper-borderless`]: !bordered,
},
className,
);
// https://github.com/ant-design/ant-design/issues/27258
[`${className}`]: !allowClear && className,
});
return (
<span
ref={this.containerRef}

7
components/input/__tests__/Search.test.js

@ -209,4 +209,11 @@ describe('Input.Search', () => {
wrapper.find('button').simulate('mousedown');
}).not.toThrow();
});
// https://github.com/ant-design/ant-design/issues/27258
it('Search with allowClear should have one className only', () => {
const wrapper = mount(<Search allowClear className="className" />);
expect(wrapper.find('.ant-input-group-wrapper').hasClass('className')).toBe(true);
expect(wrapper.find('.ant-input-affix-wrapper').hasClass('className')).toBe(false);
});
});

Loading…
Cancel
Save