Skip to content

Commit c7bedca

Browse files
authored
fix: correct long label in outlined text input (#2960)
1 parent 1684719 commit c7bedca

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

example/src/Examples/TextInputExample.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const initialState: State = {
2828
outlinedMultiline: '',
2929
outlinedTextArea: '',
3030
outlinedColors: '',
31+
outlinedLongLabel: '',
3132
maxLengthName: '',
3233
flatTextSecureEntry: true,
3334
outlineTextSecureEntry: true,
@@ -391,6 +392,15 @@ const TextInputExample = () => {
391392
outlineColor={pink400}
392393
activeOutlineColor={amber900}
393394
/>
395+
<TextInput
396+
mode="outlined"
397+
style={styles.inputContainerStyle}
398+
label="Outlined with super long label which is truncating at some point"
399+
placeholder="Type something"
400+
onChangeText={(outlinedLongLabel) =>
401+
inputActionHandler('outlinedLongLabel', outlinedLongLabel)
402+
}
403+
/>
394404
<View style={styles.inputContainerStyle}>
395405
<TextInput
396406
label="Input with helper text"

example/utils/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export type State = {
3131
outlinedMultiline: string;
3232
outlinedTextArea: string;
3333
outlinedColors: string;
34+
outlinedLongLabel: string;
3435
maxLengthName: string;
3536
flatTextSecureEntry: boolean;
3637
outlineTextSecureEntry: boolean;

src/components/TextInput/Label/LabelBackground.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ const LabelBackground = ({
7070
}),
7171
},
7272
],
73+
maxWidth:
74+
parentState.labelLayout.width -
75+
2 * placeholderStyle.paddingHorizontal,
7376
},
7477
]}
7578
numberOfLines={1}
@@ -87,7 +90,7 @@ const styles = StyleSheet.create({
8790
position: 'absolute',
8891
top: 6,
8992
left: 10,
90-
width: 8,
93+
width: 12,
9194
},
9295
outlinedLabel: {
9396
position: 'absolute',

src/components/__tests__/__snapshots__/TextInput.test.js.snap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ exports[`correctly applies height to multiline Outline TextInput 1`] = `
250250
"translateX": -3,
251251
},
252252
],
253-
"width": 8,
253+
"width": 12,
254254
}
255255
}
256256
/>
@@ -264,6 +264,7 @@ exports[`correctly applies height to multiline Outline TextInput 1`] = `
264264
"fontSize": 16,
265265
"fontWeight": undefined,
266266
"left": 18,
267+
"maxWidth": -28,
267268
"opacity": 1,
268269
"paddingHorizontal": 0,
269270
"position": "absolute",

0 commit comments

Comments
 (0)