Skip to content

Commit d957e01

Browse files
committed
Fix issue with label hiding when enableErrors is false
1 parent 6089796 commit d957e01

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

src/components/textField/Label.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ const Label = ({
1919
validationMessagePosition,
2020
floatingPlaceholder,
2121
showMandatoryIndication,
22+
enableErrors,
2223
testID
2324
}: LabelProps) => {
2425
const context = useContext(FieldContext);
2526

26-
const forceHidingLabel = !context.isValid && validationMessagePosition === ValidationMessagePosition.TOP;
27+
const forceHidingLabel =
28+
enableErrors && !context.isValid && validationMessagePosition === ValidationMessagePosition.TOP;
2729

2830
const style = useMemo(() => {
2931
return [styles.label, labelStyle, floatingPlaceholder && styles.dummyPlaceholder];

src/components/textField/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ const TextField = (props: InternalTextFieldProps) => {
139139
validationMessagePosition={validationMessagePosition}
140140
testID={`${props.testID}.label`}
141141
showMandatoryIndication={showMandatoryIndication}
142+
enableErrors={enableErrors}
142143
/>
143144
{validationMessagePosition === ValidationMessagePosition.TOP && (
144145
<ValidationMessage

src/components/textField/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export interface MandatoryIndication {
6161
showMandatoryIndication?: boolean;
6262
}
6363

64-
export interface LabelProps extends MandatoryIndication {
64+
export interface LabelProps extends MandatoryIndication, Pick<ValidationMessageProps, 'enableErrors'> {
6565
/**
6666
* Field label
6767
*/

0 commit comments

Comments
 (0)