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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
20 additions and
15 deletions
-
components/form/__tests__/__snapshots__/demo.test.js.snap
-
components/input/ClearableLabeledInput.tsx
-
components/input/__tests__/Search.test.js
|
|
@ -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" |
|
|
|
|
|
@ -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} |
|
|
|
|
|
@ -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); |
|
|
|
}); |
|
|
|
}); |
|
|
|