Skip to content

Commit 536887a

Browse files
committed
fix: input-password input-search no work
1 parent 5178480 commit 536887a

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

components/input/Input.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ import inputProps from './inputProps';
55
import { hasProp, getComponentFromProp } from '../_util/props-util';
66
import { isIE, isIE9 } from '../_util/env';
77
import { ConfigConsumerProps } from '../config-provider';
8-
import Password from './Password';
98
import Icon from '../icon';
10-
import warning from '../_util/warning';
119

1210
function noop() {}
1311

components/input/Password.js renamed to components/input/Password.jsx

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import classNames from 'classnames';
2+
import { getComponentFromProp, getOptionProps } from '../_util/props-util';
23
import Input from './Input';
34
import Icon from '../icon';
45
import inputProps from './inputProps';
@@ -57,19 +58,33 @@ export default {
5758
},
5859
},
5960
render() {
60-
const { prefixCls, inputPrefixCls, size, suffix, visibilityToggle, ...restProps } = this.$props;
61+
const { prefixCls, inputPrefixCls, size, suffix, visibilityToggle, ...restProps } = getOptionProps(this);
6162
const suffixIcon = visibilityToggle && this.getIcon();
6263
const inputClassName = classNames(prefixCls, {
6364
[`${prefixCls}-${size}`]: !!size,
6465
});
66+
const inputProps = {
67+
props: {
68+
...restProps,
69+
prefixCls: inputPrefixCls,
70+
size,
71+
suffix: suffixIcon,
72+
prefix: getComponentFromProp(this, 'prefix'),
73+
addonAfter: getComponentFromProp(this, 'addonAfter'),
74+
addonBefore: getComponentFromProp(this, 'addonBefore'),
75+
},
76+
attrs: {
77+
...this.$attrs,
78+
type: this.visible ? 'text' : 'password',
79+
},
80+
class: inputClassName,
81+
on: {
82+
...this.$listeners,
83+
},
84+
};
6585
return (
6686
<Input
67-
{...restProps}
68-
type={this.visible ? 'text' : 'password'}
69-
size={size}
70-
class={inputClassName}
71-
prefixCls={inputPrefixCls}
72-
suffix={suffixIcon}
87+
{...inputProps}
7388
/>
7489
);
7590
},

components/input/Search.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ export default {
127127
prefixCls: inputPrefixCls,
128128
size,
129129
suffix: this.renderSuffix(prefixCls),
130+
prefix: getComponentFromProp(this, 'prefix'),
130131
addonAfter: this.renderAddonAfter(prefixCls),
131132
addonBefore,
132133
},

0 commit comments

Comments
 (0)