chore: add focus warning for Input (#34475)

* chore: add focus warning for Input

* chore: code clean

* chore: remove duplicate variables
This commit is contained in:
MadCcc 2022-03-14 15:37:02 +08:00 committed by GitHub
parent 14e719295e
commit c9b6a24978
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -149,7 +149,7 @@ const Input = forwardRef<InputRef, InputProps>((props, ref) => {
const mergedStatus = getMergedStatus(contextStatus, customStatus); const mergedStatus = getMergedStatus(contextStatus, customStatus);
// ===================== Focus warning ===================== // ===================== Focus warning =====================
const inputHasPrefixSuffix = hasPrefixSuffix(props); const inputHasPrefixSuffix = hasPrefixSuffix(props) || !!hasFeedback;
const prevHasPrefixSuffix = useRef<boolean>(inputHasPrefixSuffix); const prevHasPrefixSuffix = useRef<boolean>(inputHasPrefixSuffix);
useEffect(() => { useEffect(() => {
if (inputHasPrefixSuffix && !prevHasPrefixSuffix.current) { if (inputHasPrefixSuffix && !prevHasPrefixSuffix.current) {
@ -200,8 +200,6 @@ const Input = forwardRef<InputRef, InputProps>((props, ref) => {
</> </>
); );
const withPrefixSuffix = hasPrefixSuffix(props) || hasFeedback;
// Allow clear // Allow clear
let mergedAllowClear; let mergedAllowClear;
if (typeof allowClear === 'object' && allowClear?.clearIcon) { if (typeof allowClear === 'object' && allowClear?.clearIcon) {
@ -229,7 +227,7 @@ const Input = forwardRef<InputRef, InputProps>((props, ref) => {
[`${prefixCls}-rtl`]: direction === 'rtl', [`${prefixCls}-rtl`]: direction === 'rtl',
[`${prefixCls}-borderless`]: !bordered, [`${prefixCls}-borderless`]: !bordered,
}, },
!withPrefixSuffix && getStatusClassNames(prefixCls, mergedStatus), !inputHasPrefixSuffix && getStatusClassNames(prefixCls, mergedStatus),
)} )}
affixWrapperClassName={classNames( affixWrapperClassName={classNames(
{ {