Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: outlined TexInput adjustPaddingOut (#2740) #2793

Merged
merged 5 commits into from
Jul 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/TextInput/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export const adjustPaddingOut = ({
const refFontHeight = scale * fontSize;
let result = pad;

if (height) {
if (height && !multiline) {
return {
paddingTop: Math.max(0, (height - fontHeight) / 2),
paddingBottom: Math.max(0, (height - fontHeight) / 2),
Expand Down
15 changes: 15 additions & 0 deletions src/components/__tests__/TextInput.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,18 @@ it('correctly applies textAlign center', () => {

expect(toJSON()).toMatchSnapshot();
});

it('correctly applies height to multiline Outline TextInput', () => {
const { toJSON } = render(
<TextInput
Kamalnrf marked this conversation as resolved.
Show resolved Hide resolved
mode="outlined"
label="Outline Input"
placeholder="Type Something"
value={'Some test value'}
style={{ height: 100 }}
multiline
/>
);

expect(toJSON()).toMatchSnapshot();
});
223 changes: 223 additions & 0 deletions src/components/__tests__/__snapshots__/TextInput.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,229 @@ exports[`correctly applies default textAlign based on default RTL 1`] = `
</View>
`;

exports[`correctly applies height to multiline Outline TextInput 1`] = `
<View
style={Object {}}
>
<View>
<View
pointerEvents="none"
style={
Array [
Object {
"bottom": 0,
"left": 0,
"position": "absolute",
"right": 0,
"top": 6,
},
Object {
"backgroundColor": "#f6f6f6",
"borderColor": "rgba(0, 0, 0, 0.54)",
"borderRadius": 4,
"borderWidth": 1,
},
]
}
/>
<View
style={
Array [
Object {
"paddingBottom": 0,
},
Object {
"minHeight": 100,
"paddingTop": 8,
},
]
}
>
<View
pointerEvents="none"
style={
Object {
"bottom": 0,
"left": 0,
"opacity": 0,
"position": "absolute",
"right": 0,
"top": 0,
"transform": Array [
Object {
"translateX": 3,
},
],
}
}
>
<View
pointerEvents="none"
style={
Object {
"backgroundColor": "#f6f6f6",
"bottom": 4,
"left": 10,
"opacity": 1,
"position": "absolute",
"right": 0,
"top": 6,
"transform": Array [
Object {
"translateX": -3,
},
],
"width": 8,
}
}
/>
<Text
numberOfLines={1}
style={
Object {
"backgroundColor": "#f6f6f6",
"color": "transparent",
"fontFamily": "System",
"fontSize": 16,
"fontWeight": undefined,
"left": 18,
"opacity": 1,
"paddingHorizontal": 0,
"position": "absolute",
"textAlign": "left",
"top": 59,
"transform": Array [
Object {
"translateX": 0,
},
Object {
"translateY": -52,
},
Object {
"scale": 0.75,
},
Object {
"scaleY": 0.2,
},
],
"writingDirection": "ltr",
}
}
>
Outline Input
</Text>
<Text
numberOfLines={1}
onLayout={[Function]}
style={
Object {
"color": "#6200ee",
"fontFamily": "System",
"fontSize": 16,
"fontWeight": undefined,
"left": 0,
"opacity": 0,
"paddingHorizontal": 14,
"position": "absolute",
"textAlign": "left",
"top": 58,
"transform": Array [
Object {
"translateX": 0,
},
Object {
"translateY": -52,
},
Object {
"scale": 0.75,
},
],
"writingDirection": "ltr",
}
}
>
Outline Input
</Text>
<Text
numberOfLines={1}
style={
Object {
"color": "rgba(0, 0, 0, 0.54)",
"fontFamily": "System",
"fontSize": 16,
"fontWeight": undefined,
"left": 0,
"opacity": 0,
"paddingHorizontal": 14,
"position": "absolute",
"textAlign": "left",
"top": 58,
"transform": Array [
Object {
"translateX": 0,
},
Object {
"translateY": -52,
},
Object {
"scale": 0.75,
},
],
"writingDirection": "ltr",
}
}
>
Outline Input
</Text>
</View>
<TextInput
allowFontScaling={true}
editable={true}
multiline={true}
onBlur={[Function]}
onChangeText={[Function]}
onFocus={[Function]}
placeholder=""
placeholderTextColor="rgba(0, 0, 0, 0.54)"
rejectResponderTermination={true}
selectionColor="#6200ee"
style={
Array [
Object {
"flexGrow": 1,
"margin": 0,
"paddingHorizontal": 14,
"zIndex": 1,
},
Object {
"height": 100,
},
Object {
"paddingBottom": 24,
"paddingTop": 24,
},
Object {
"color": "#000000",
"fontFamily": "System",
"fontSize": 16,
"fontWeight": undefined,
"textAlign": "left",
"textAlignVertical": "top",
},
false,
Array [
Object {},
],
]
}
underlineColorAndroid="transparent"
value="Some test value"
/>
</View>
</View>
</View>
`;

exports[`correctly applies textAlign center 1`] = `
<View
style={
Expand Down