Skip to content

Commit

Permalink
fix: custom input styling in TextInput (#3648) (#3649)
Browse files Browse the repository at this point in the history
  • Loading branch information
tjaniczek authored Feb 6, 2023
1 parent 0970f64 commit e4c2e9d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
4 changes: 3 additions & 1 deletion example/src/Examples/TextInputExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ const TextInputExample = () => {
mode="flat"
style={styles.inputContainerStyle}
label="Custom style input"
placeholder="Input with custom padding"
placeholder="Input with custom style"
value={customStyleText}
onChangeText={(customStyleText) =>
inputActionHandler('customStyleText', customStyleText)
Expand Down Expand Up @@ -628,6 +628,8 @@ const styles = StyleSheet.create({
},
inputContentStyle: {
paddingLeft: 50,
fontWeight: 'bold',
fontStyle: 'italic',
},
fontSize: {
fontSize: 32,
Expand Down
12 changes: 6 additions & 6 deletions src/components/TextInput/Label/InputLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const InputLabel = (props: InputLabelProps) => {
labelTranslationXOffset,
maxFontSizeMultiplier,
testID,
contentStyle,
theme,
} = props.labelProps;

Expand All @@ -50,10 +49,12 @@ const InputLabel = (props: InputLabelProps) => {
fontSize,
lineHeight,
fontWeight,
opacity: parentState.labeled.interpolate({
inputRange: [0, 1],
outputRange: [hasActiveOutline ? 1 : 0, 0],
}),
opacity: hasActiveOutline
? parentState.labeled.interpolate({
inputRange: [0, 1],
outputRange: [1, 0],
})
: 0,
transform: [
{
// Wiggle the label when there's an error
Expand Down Expand Up @@ -148,7 +149,6 @@ const InputLabel = (props: InputLabelProps) => {
color: textColor,
opacity: placeholderOpacity,
},
contentStyle,
]}
numberOfLines={1}
maxFontSizeMultiplier={maxFontSizeMultiplier}
Expand Down
1 change: 0 additions & 1 deletion src/components/TextInput/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,6 @@ const TextInput = forwardRef<TextInputHandles, Props>(
// Root cause: Placeholder initial value, which has length 0.
// More context: The issue was also reproduced in react-native, using its own TextInput.
// Workaround: Set an empty space character in the default value.

setPlaceholder(' ');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ exports[`correctly applies paddingLeft from contentStyleProp 1`] = `
"letterSpacing": 0.15,
"lineHeight": undefined,
"opacity": 0,
"paddingLeft": 20,
"paddingLeft": 16,
"paddingRight": 16,
"position": "absolute",
"textAlign": "left",
Expand Down

0 comments on commit e4c2e9d

Please sign in to comment.