mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-07 17:44:35 +08:00
fix: Input can not be hidden when prefix is set (#33706)
* fix: Input can not be hidden when prefix is set * test: jest case for #33692 Co-authored-by: hydraZty <hydra_zty@163.com>
This commit is contained in:
parent
2d484bbe47
commit
aecf52e4b0
@ -29,6 +29,7 @@ interface BasicProps {
|
||||
focused?: boolean;
|
||||
readOnly?: boolean;
|
||||
bordered: boolean;
|
||||
hidden?: boolean;
|
||||
}
|
||||
|
||||
/** This props only for input. */
|
||||
@ -104,6 +105,7 @@ class ClearableLabeledInput extends React.Component<ClearableInputProps> {
|
||||
style,
|
||||
readOnly,
|
||||
bordered,
|
||||
hidden,
|
||||
} = this.props;
|
||||
if (!hasPrefixSuffix(this.props)) {
|
||||
return cloneElement(element, {
|
||||
@ -132,6 +134,7 @@ class ClearableLabeledInput extends React.Component<ClearableInputProps> {
|
||||
className={affixWrapperCls}
|
||||
style={style}
|
||||
onMouseUp={this.onInputMouseUp}
|
||||
hidden={hidden}
|
||||
>
|
||||
{prefixNode}
|
||||
{cloneElement(element, {
|
||||
|
@ -97,6 +97,18 @@ describe('prefix and suffix', () => {
|
||||
expect(wrapper.getDOMNode().className.includes('my-class-name')).toBe(true);
|
||||
expect(wrapper.find('input').getDOMNode().className.includes('my-class-name')).toBe(false);
|
||||
});
|
||||
|
||||
it('should support hidden when has prefix or suffix', () => {
|
||||
const wrapper = mount(
|
||||
<>
|
||||
<Input prefix="prefix" hidden className="prefix-with-hidden" />
|
||||
<Input suffix="suffix" hidden className="suffix-with-hidden" />
|
||||
</>,
|
||||
);
|
||||
|
||||
expect(wrapper.find('.prefix-with-hidden').at(0).getDOMNode().hidden).toBe(true);
|
||||
expect(wrapper.find('.suffix-with-hidden').at(0).getDOMNode().hidden).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('As Form Control', () => {
|
||||
|
Loading…
Reference in New Issue
Block a user