Skip to content

Commit

Permalink
fix: correct long label in outlined text input (#2960)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukewalczak authored Dec 10, 2021
1 parent 1684719 commit c7bedca
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
10 changes: 10 additions & 0 deletions example/src/Examples/TextInputExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const initialState: State = {
outlinedMultiline: '',
outlinedTextArea: '',
outlinedColors: '',
outlinedLongLabel: '',
maxLengthName: '',
flatTextSecureEntry: true,
outlineTextSecureEntry: true,
Expand Down Expand Up @@ -391,6 +392,15 @@ const TextInputExample = () => {
outlineColor={pink400}
activeOutlineColor={amber900}
/>
<TextInput
mode="outlined"
style={styles.inputContainerStyle}
label="Outlined with super long label which is truncating at some point"
placeholder="Type something"
onChangeText={(outlinedLongLabel) =>
inputActionHandler('outlinedLongLabel', outlinedLongLabel)
}
/>
<View style={styles.inputContainerStyle}>
<TextInput
label="Input with helper text"
Expand Down
1 change: 1 addition & 0 deletions example/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export type State = {
outlinedMultiline: string;
outlinedTextArea: string;
outlinedColors: string;
outlinedLongLabel: string;
maxLengthName: string;
flatTextSecureEntry: boolean;
outlineTextSecureEntry: boolean;
Expand Down
5 changes: 4 additions & 1 deletion src/components/TextInput/Label/LabelBackground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ const LabelBackground = ({
}),
},
],
maxWidth:
parentState.labelLayout.width -
2 * placeholderStyle.paddingHorizontal,
},
]}
numberOfLines={1}
Expand All @@ -87,7 +90,7 @@ const styles = StyleSheet.create({
position: 'absolute',
top: 6,
left: 10,
width: 8,
width: 12,
},
outlinedLabel: {
position: 'absolute',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ exports[`correctly applies height to multiline Outline TextInput 1`] = `
"translateX": -3,
},
],
"width": 8,
"width": 12,
}
}
/>
Expand All @@ -264,6 +264,7 @@ exports[`correctly applies height to multiline Outline TextInput 1`] = `
"fontSize": 16,
"fontWeight": undefined,
"left": 18,
"maxWidth": -28,
"opacity": 1,
"paddingHorizontal": 0,
"position": "absolute",
Expand Down

0 comments on commit c7bedca

Please sign in to comment.