Skip to content

Commit 70ce3c9

Browse files
committed
Passed showMandatoryIndication prop from the text field to the label
1 parent 16baa11 commit 70ce3c9

File tree

1 file changed

+7
-30
lines changed

1 file changed

+7
-30
lines changed

src/incubator/TextField/index.tsx

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -126,42 +126,19 @@ const TextField = (props: InternalTextFieldProps) => {
126126
return [inputStyle, styles.dummyPlaceholder];
127127
}, [inputStyle]);
128128

129-
let textFieldLabel = (
130-
<Label
131-
label={label}
132-
labelColor={labelColor}
133-
labelStyle={_labelStyle}
134-
labelProps={labelProps}
135-
floatingPlaceholder={floatingPlaceholder}
136-
validationMessagePosition={validationMessagePosition}
137-
testID={`${props.testID}.label`}
138-
/>
139-
);
140-
const textFieldIsRequired =
141-
(typeof others.validate === 'string' && others.validate === 'required') ||
142-
(Array.isArray(others.validate) && others.validate.includes('required'));
143-
144-
if (showMandatoryIndication && textFieldIsRequired) {
145-
textFieldLabel = (
146-
<View row>
147-
{textFieldLabel}
129+
return (
130+
<FieldContext.Provider value={context}>
131+
<View {...containerProps} style={[margins, positionStyle, containerStyle, centeredContainerStyle]}>
148132
<Label
149-
label={'*'}
150-
labelColor={Colors.red30} // TODO: Decide how and which color should be here.
133+
label={label}
134+
labelColor={labelColor}
151135
labelStyle={_labelStyle}
152136
labelProps={labelProps}
153137
floatingPlaceholder={floatingPlaceholder}
154138
validationMessagePosition={validationMessagePosition}
155-
testID={`${props.testID}.label.mandatory`}
139+
testID={`${props.testID}.label`}
140+
showMandatoryIndication={showMandatoryIndication}
156141
/>
157-
</View>
158-
);
159-
}
160-
161-
return (
162-
<FieldContext.Provider value={context}>
163-
<View {...containerProps} style={[margins, positionStyle, containerStyle, centeredContainerStyle]}>
164-
{textFieldLabel}
165142
{validationMessagePosition === ValidationMessagePosition.TOP && (
166143
<ValidationMessage
167144
enableErrors={enableErrors}

0 commit comments

Comments
 (0)