mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-28 21:19:37 +08:00
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:
parent
14e719295e
commit
c9b6a24978
@ -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(
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user