Skip to content

fix(input-password): accept global prefixCls #4280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions components/input/Password.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Icon from '../icon';
import inputProps from './inputProps';
import PropTypes from '../_util/vue-types';
import BaseMixin from '../_util/BaseMixin';
import { ConfigConsumerProps } from '../config-provider/configConsumerProps';

const ActionMap = {
click: 'click',
Expand All @@ -21,11 +22,14 @@ export default {
},
props: {
...inputProps,
prefixCls: PropTypes.string.def('ant-input-password'),
inputPrefixCls: PropTypes.string.def('ant-input'),
prefixCls: PropTypes.string,
inputPrefixCls: PropTypes.string,
action: PropTypes.string.def('click'),
visibilityToggle: PropTypes.bool.def(true),
},
inject: {
configProvider: { default: () => ConfigConsumerProps },
},
data() {
return {
visible: false,
Expand All @@ -46,8 +50,8 @@ export default {
visible: !this.visible,
});
},
getIcon() {
const { prefixCls, action } = this.$props;
getIcon(prefixCls) {
const { action } = this.$props;
const iconTrigger = ActionMap[action] || '';
const iconProps = {
props: {
Expand All @@ -74,14 +78,19 @@ export default {
},
render() {
const {
prefixCls,
inputPrefixCls,
prefixCls: customizePrefixCls,
inputPrefixCls: customizeInputPrefixCls,
size,
suffix,
visibilityToggle,
...restProps
} = getOptionProps(this);
const suffixIcon = visibilityToggle && this.getIcon();

const getPrefixCls = this.configProvider.getPrefixCls;
const inputPrefixCls = getPrefixCls('input', customizeInputPrefixCls);
const prefixCls = getPrefixCls('input-password', customizePrefixCls);

const suffixIcon = visibilityToggle && this.getIcon(prefixCls);
const inputClassName = classNames(prefixCls, {
[`${prefixCls}-${size}`]: !!size,
});
Expand Down