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(text-input): parent scroll with text input height #4422

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
4 changes: 3 additions & 1 deletion src/components/TextInput/TextInputFlat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ const TextInputFlat = ({
multiline,
style: [
styles.input,
!multiline || (multiline && height) ? { height: flatHeight } : {},
multiline && height ? { height: flatHeight } : {},
paddingFlat,
{
paddingLeft,
Expand Down Expand Up @@ -440,9 +440,11 @@ const styles = StyleSheet.create({
labelContainer: {
paddingTop: 0,
paddingBottom: 0,
flex: 1,
},
input: {
margin: 0,
flex: 1,
},
inputFlat: {
paddingTop: 24,
Expand Down
5 changes: 3 additions & 2 deletions src/components/TextInput/TextInputOutlined.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,7 @@ const TextInputOutlined = ({
(dense ? MIN_DENSE_HEIGHT_OUTLINED : MIN_HEIGHT)) as number;

const outlinedHeight =
inputHeight + (!height ? (dense ? densePaddingTop / 2 : paddingTop) : 0);

inputHeight + (dense ? densePaddingTop / 2 : paddingTop);
const { leftLayout, rightLayout } = parentState;

const leftAffixTopPosition = calculateOutlinedIconAndAffixTopPosition({
Expand Down Expand Up @@ -427,9 +426,11 @@ export default TextInputOutlined;
const styles = StyleSheet.create({
labelContainer: {
paddingBottom: 0,
flex: 1,
},
input: {
margin: 0,
flex: 1,
},
inputOutlined: {
paddingTop: 8,
Expand Down
2 changes: 1 addition & 1 deletion src/components/TextInput/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export const adjustPaddingOut = ({
const refFontHeight = scale * fontSize;
let result = pad;

if (height && !multiline) {
if (!isAndroid && height && !multiline) {
return {
paddingTop: Math.max(0, (height - fontHeight) / 2),
paddingBottom: Math.max(0, (height - fontHeight) / 2),
Expand Down
50 changes: 26 additions & 24 deletions src/components/__tests__/__snapshots__/TextInput.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ exports[`call onPress when affix adornment pressed 1`] = `
style={
[
{
"flex": 1,
"paddingBottom": 0,
"paddingTop": 0,
},
Expand Down Expand Up @@ -160,11 +161,10 @@ exports[`call onPress when affix adornment pressed 1`] = `
style={
[
{
"flex": 1,
"margin": 0,
},
{
"height": 56,
},
{},
{
"paddingBottom": 4,
"paddingTop": 24,
Expand Down Expand Up @@ -318,6 +318,7 @@ exports[`correctly applies a component as the text label 1`] = `
style={
[
{
"flex": 1,
"paddingBottom": 0,
"paddingTop": 0,
},
Expand Down Expand Up @@ -457,11 +458,10 @@ exports[`correctly applies a component as the text label 1`] = `
style={
[
{
"flex": 1,
"margin": 0,
},
{
"height": 56,
},
{},
{
"paddingBottom": 4,
"paddingTop": 24,
Expand Down Expand Up @@ -532,6 +532,7 @@ exports[`correctly applies cursorColor prop 1`] = `
style={
[
{
"flex": 1,
"paddingBottom": 0,
"paddingTop": 0,
},
Expand Down Expand Up @@ -655,11 +656,10 @@ exports[`correctly applies cursorColor prop 1`] = `
style={
[
{
"flex": 1,
"margin": 0,
},
{
"height": 56,
},
{},
{
"paddingBottom": 4,
"paddingTop": 24,
Expand Down Expand Up @@ -730,6 +730,7 @@ exports[`correctly applies default textAlign based on default RTL 1`] = `
style={
[
{
"flex": 1,
"paddingBottom": 0,
"paddingTop": 0,
},
Expand Down Expand Up @@ -853,11 +854,10 @@ exports[`correctly applies default textAlign based on default RTL 1`] = `
style={
[
{
"flex": 1,
"margin": 0,
},
{
"height": 56,
},
{},
{
"paddingBottom": 4,
"paddingTop": 24,
Expand Down Expand Up @@ -921,6 +921,7 @@ exports[`correctly applies height to multiline Outline TextInput 1`] = `
style={
[
{
"flex": 1,
"paddingBottom": 0,
},
{
Expand Down Expand Up @@ -1084,6 +1085,7 @@ exports[`correctly applies height to multiline Outline TextInput 1`] = `
style={
[
{
"flex": 1,
"margin": 0,
},
{
Expand Down Expand Up @@ -1158,6 +1160,7 @@ exports[`correctly applies paddingLeft from contentStyleProp 1`] = `
style={
[
{
"flex": 1,
"paddingBottom": 0,
"paddingTop": 0,
},
Expand Down Expand Up @@ -1281,11 +1284,10 @@ exports[`correctly applies paddingLeft from contentStyleProp 1`] = `
style={
[
{
"flex": 1,
"margin": 0,
},
{
"height": 56,
},
{},
{
"paddingBottom": 4,
"paddingTop": 24,
Expand Down Expand Up @@ -1358,6 +1360,7 @@ exports[`correctly applies textAlign center 1`] = `
style={
[
{
"flex": 1,
"paddingBottom": 0,
"paddingTop": 0,
},
Expand Down Expand Up @@ -1481,11 +1484,10 @@ exports[`correctly applies textAlign center 1`] = `
style={
[
{
"flex": 1,
"margin": 0,
},
{
"height": 56,
},
{},
{
"paddingBottom": 4,
"paddingTop": 24,
Expand Down Expand Up @@ -1556,6 +1558,7 @@ exports[`correctly renders left-side affix adornment, and right-side icon adornm
style={
[
{
"flex": 1,
"paddingBottom": 0,
"paddingTop": 0,
},
Expand Down Expand Up @@ -1679,11 +1682,10 @@ exports[`correctly renders left-side affix adornment, and right-side icon adornm
style={
[
{
"flex": 1,
"margin": 0,
},
{
"height": 56,
},
{},
{
"paddingBottom": 4,
"paddingTop": 24,
Expand Down Expand Up @@ -1956,6 +1958,7 @@ exports[`correctly renders left-side icon adornment, and right-side affix adornm
style={
[
{
"flex": 1,
"paddingBottom": 0,
"paddingTop": 0,
},
Expand Down Expand Up @@ -2079,11 +2082,10 @@ exports[`correctly renders left-side icon adornment, and right-side affix adornm
style={
[
{
"flex": 1,
"margin": 0,
},
{
"height": 56,
},
{},
{
"paddingBottom": 4,
"paddingTop": 24,
Expand Down
Loading