From 4e471db343709952a06095992deb305ba5862ba4 Mon Sep 17 00:00:00 2001 From: TDiDa <> Date: Fri, 6 Mar 2020 23:19:41 +0800 Subject: [PATCH 1/2] fix: Input.Password ConfigProvider prefixCls not work --- components/input/Password.tsx | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/components/input/Password.tsx b/components/input/Password.tsx index 5d80c472d229..e3b3ae4fe386 100644 --- a/components/input/Password.tsx +++ b/components/input/Password.tsx @@ -4,6 +4,7 @@ import omit from 'omit.js'; import EyeOutlined from '@ant-design/icons/EyeOutlined'; import EyeInvisibleOutlined from '@ant-design/icons/EyeInvisibleOutlined'; +import { ConfigConsumer, ConfigConsumerProps } from '../config-provider'; import Input, { InputProps } from './Input'; export interface PasswordProps extends InputProps { @@ -25,8 +26,6 @@ export default class Password extends React.Component ({ visible: !visible })); }; - getIcon() { - const { prefixCls, action } = this.props; + getIcon = (prefixCls: string) => { + const { action } = this.props; const iconTrigger = ActionMap[action!] || ''; const icon = this.state.visible ? EyeOutlined : EyeInvisibleOutlined; const iconProps = { @@ -59,7 +58,7 @@ export default class Password extends React.Component { if (instance && instance.input) { @@ -79,19 +78,24 @@ export default class Password extends React.Component { const { className, - prefixCls, - inputPrefixCls, + prefixCls: customizePrefixCls, + inputPrefixCls: customizeInputPrefixCls, size, visibilityToggle, ...restProps } = this.props; - const suffixIcon = visibilityToggle && this.getIcon(); + + const inputPrefixCls = getPrefixCls('input', customizeInputPrefixCls); + const prefixCls = getPrefixCls('input-password', customizePrefixCls); + + const suffixIcon = visibilityToggle && this.getIcon(prefixCls); const inputClassName = classNames(prefixCls, className, { [`${prefixCls}-${size}`]: !!size, }); + const props = { ...omit(restProps, ['suffix']), type: this.state.visible ? 'text' : 'password', @@ -100,9 +104,15 @@ export default class Password extends React.Component; + }; + + render() { + return {this.renderPassword}; } } From e5f917dcc6f6a4afc51c38cf8d0223fb58dd9dae Mon Sep 17 00:00:00 2001 From: TDiDa <> Date: Sat, 7 Mar 2020 00:15:12 +0800 Subject: [PATCH 2/2] test: add ConfigProvider Input.Password test --- .../__snapshots__/components.test.js.snap | 114 ++++++++++++++++++ .../__tests__/components.test.js | 1 + 2 files changed, 115 insertions(+) diff --git a/components/config-provider/__tests__/__snapshots__/components.test.js.snap b/components/config-provider/__tests__/__snapshots__/components.test.js.snap index 48aa062fc13b..b3106dce12d7 100644 --- a/components/config-provider/__tests__/__snapshots__/components.test.js.snap +++ b/components/config-provider/__tests__/__snapshots__/components.test.js.snap @@ -7155,6 +7155,44 @@ exports[`ConfigProvider components Input configProvider 1`] = ` + + + + + + + +