Skip to content

Commit 2b55073

Browse files
authored
Retain TextField top validation message when needed (#1990)
1 parent 3fc3896 commit 2b55073

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/incubator/TextField/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* other elements (leading/trailing accessories). It usually best to set lineHeight with undefined
77
*/
88
import React, {useMemo} from 'react';
9-
import {omit} from 'lodash';
9+
import {isEmpty, trim, omit} from 'lodash';
1010
import {asBaseComponent, forwardRef} from '../../commons/new';
1111
import View from '../../components/view';
1212
import {Colors} from '../../style';
@@ -87,6 +87,7 @@ const TextField = (props: InternalTextFieldProps) => {
8787

8888
const fieldStyle = [fieldStyleProp, dynamicFieldStyle?.(context, {preset: props.preset})];
8989
const hidePlaceholder = shouldHidePlaceholder(props, fieldState.isFocused);
90+
const retainTopMessageSpace = !floatingPlaceholder && isEmpty(trim(label));
9091

9192
return (
9293
<FieldContext.Provider value={context}>
@@ -106,6 +107,7 @@ const TextField = (props: InternalTextFieldProps) => {
106107
validate={others.validate}
107108
validationMessage={others.validationMessage}
108109
validationMessageStyle={validationMessageStyle}
110+
retainSpace={retainTopMessageSpace}
109111
testID={`${props.testID}.validationMessage`}
110112
/>
111113
)}

0 commit comments

Comments
 (0)