Skip to content

Commit 1b53959

Browse files
matveyokethanshar
andauthored
TextField - pass testID to internal Label component (#1736)
* feat(TextField): pass testID to internal Label component * Add generated types Co-authored-by: Ethan Sharabi <[email protected]>
1 parent 41aa875 commit 1b53959

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

generatedTypes/src/incubator/TextField/Label.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ export interface LabelProps {
2121
labelProps?: TextProps;
2222
validationMessagePosition?: ValidationMessagePosition;
2323
floatingPlaceholder?: boolean;
24+
testID?: string;
2425
}
2526
declare const Label: {
26-
({ label, labelColor, labelStyle, labelProps, validationMessagePosition, floatingPlaceholder }: LabelProps): JSX.Element | null;
27+
({ label, labelColor, labelStyle, labelProps, validationMessagePosition, floatingPlaceholder, testID }: LabelProps): JSX.Element | null;
2728
displayName: string;
2829
};
2930
export default Label;

src/incubator/TextField/Label.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export interface LabelProps {
2525
labelProps?: TextProps;
2626
validationMessagePosition?: ValidationMessagePosition;
2727
floatingPlaceholder?: boolean;
28+
testID?: string;
2829
}
2930

3031
const Label = ({
@@ -33,7 +34,8 @@ const Label = ({
3334
labelStyle,
3435
labelProps,
3536
validationMessagePosition,
36-
floatingPlaceholder
37+
floatingPlaceholder,
38+
testID
3739
}: LabelProps) => {
3840
const context = useContext(FieldContext);
3941

@@ -42,6 +44,7 @@ const Label = ({
4244
if ((label || floatingPlaceholder) && !forceHidingLabel) {
4345
return (
4446
<Text
47+
testID={testID}
4548
color={getColorByState(labelColor, context)}
4649
style={[styles.label, labelStyle, floatingPlaceholder && styles.dummyPlaceholder]}
4750
{...labelProps}

src/incubator/TextField/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ const TextField = (props: InternalTextFieldProps) => {
184184
labelProps={labelProps}
185185
floatingPlaceholder={floatingPlaceholder}
186186
validationMessagePosition={validationMessagePosition}
187+
testID={`${props.testID}.label`}
187188
/>
188189
{validationMessagePosition === ValidationMessagePosition.TOP && (
189190
<ValidationMessage

0 commit comments

Comments
 (0)