From 08a2d492617cafa012165e904981a1fa42ecf0ea Mon Sep 17 00:00:00 2001 From: Serhii Date: Sat, 15 Feb 2020 18:43:19 +0100 Subject: [PATCH 01/10] wip --- packages/material-ui/src/TextField/TextField.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/material-ui/src/TextField/TextField.js b/packages/material-ui/src/TextField/TextField.js index 908958231cf6f7..a93f2c288ad767 100644 --- a/packages/material-ui/src/TextField/TextField.js +++ b/packages/material-ui/src/TextField/TextField.js @@ -106,15 +106,14 @@ const TextField = React.forwardRef(function TextField(props, ref) { if (InputLabelProps && typeof InputLabelProps.shrink !== 'undefined') { InputMore.notched = InputLabelProps.shrink; } - - InputMore.label = label ? ( - - {label} - {required && '\u00a0*'} - - ) : ( - label - ); + if (label) { + InputMore.label = ( + + {label} + {required && '\u00a0*'} + + ); + } } if (select) { // unset defaults from textbox inputs From 28ed0f79a231a9eadc13a7c1baa5497dbba1d31d Mon Sep 17 00:00:00 2001 From: Serhii Date: Sat, 15 Feb 2020 19:03:15 +0100 Subject: [PATCH 02/10] add unit tests --- packages/material-ui/src/TextField/TextField.test.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/material-ui/src/TextField/TextField.test.js b/packages/material-ui/src/TextField/TextField.test.js index cc0d1ba40746aa..23eefe9622c674 100644 --- a/packages/material-ui/src/TextField/TextField.test.js +++ b/packages/material-ui/src/TextField/TextField.test.js @@ -62,6 +62,16 @@ describe('', () => { expect(container.querySelector('label')).to.have.class('foo'); }); + it('should not render empty label element', () => { + const { container } = render(); + + expect(container.querySelector('label')).to.be.null; + }); + it('should not render undefined label element', () => { + const { container } = render(); + + expect(container.querySelector('label')).to.be.null; + }); }); describe('with a helper text', () => { From 1406762b4ded588551efa70b3416e0218aa2cfe3 Mon Sep 17 00:00:00 2001 From: Serhii Date: Sat, 15 Feb 2020 19:09:28 +0100 Subject: [PATCH 03/10] fix test --- packages/material-ui/src/TextField/TextField.js | 2 +- packages/material-ui/src/TextField/TextField.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/material-ui/src/TextField/TextField.js b/packages/material-ui/src/TextField/TextField.js index a93f2c288ad767..cb1ac10b30e120 100644 --- a/packages/material-ui/src/TextField/TextField.js +++ b/packages/material-ui/src/TextField/TextField.js @@ -106,7 +106,7 @@ const TextField = React.forwardRef(function TextField(props, ref) { if (InputLabelProps && typeof InputLabelProps.shrink !== 'undefined') { InputMore.notched = InputLabelProps.shrink; } - if (label) { + if (typeof label === 'string' && label.length > 0) { InputMore.label = ( {label} diff --git a/packages/material-ui/src/TextField/TextField.test.js b/packages/material-ui/src/TextField/TextField.test.js index 23eefe9622c674..f6a9d69ddf8541 100644 --- a/packages/material-ui/src/TextField/TextField.test.js +++ b/packages/material-ui/src/TextField/TextField.test.js @@ -63,7 +63,7 @@ describe('', () => { expect(container.querySelector('label')).to.have.class('foo'); }); it('should not render empty label element', () => { - const { container } = render(); + const { container } = render(); expect(container.querySelector('label')).to.be.null; }); From faa1322d3d3d9d869d318478fb55bc074f53b980 Mon Sep 17 00:00:00 2001 From: Serhii Date: Sat, 15 Feb 2020 19:14:21 +0100 Subject: [PATCH 04/10] fix --- packages/material-ui/src/TextField/TextField.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/material-ui/src/TextField/TextField.js b/packages/material-ui/src/TextField/TextField.js index cb1ac10b30e120..a93f2c288ad767 100644 --- a/packages/material-ui/src/TextField/TextField.js +++ b/packages/material-ui/src/TextField/TextField.js @@ -106,7 +106,7 @@ const TextField = React.forwardRef(function TextField(props, ref) { if (InputLabelProps && typeof InputLabelProps.shrink !== 'undefined') { InputMore.notched = InputLabelProps.shrink; } - if (typeof label === 'string' && label.length > 0) { + if (label) { InputMore.label = ( {label} From 06f6357508a41babf0ac35bd98e5bdff3902ae6a Mon Sep 17 00:00:00 2001 From: Serhii Date: Sat, 15 Feb 2020 19:53:35 +0100 Subject: [PATCH 05/10] trigger azure pipeline --- packages/material-ui/src/TextField/TextField.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/material-ui/src/TextField/TextField.js b/packages/material-ui/src/TextField/TextField.js index a93f2c288ad767..1836a60adc821e 100644 --- a/packages/material-ui/src/TextField/TextField.js +++ b/packages/material-ui/src/TextField/TextField.js @@ -106,7 +106,7 @@ const TextField = React.forwardRef(function TextField(props, ref) { if (InputLabelProps && typeof InputLabelProps.shrink !== 'undefined') { InputMore.notched = InputLabelProps.shrink; } - if (label) { + if (label ) { InputMore.label = ( {label} From 336b509e2aa9b044c0065fcb7117549bcc725eb1 Mon Sep 17 00:00:00 2001 From: Serhii Date: Sat, 15 Feb 2020 19:54:12 +0100 Subject: [PATCH 06/10] prettier --- packages/material-ui/src/TextField/TextField.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/material-ui/src/TextField/TextField.js b/packages/material-ui/src/TextField/TextField.js index 1836a60adc821e..a93f2c288ad767 100644 --- a/packages/material-ui/src/TextField/TextField.js +++ b/packages/material-ui/src/TextField/TextField.js @@ -106,7 +106,7 @@ const TextField = React.forwardRef(function TextField(props, ref) { if (InputLabelProps && typeof InputLabelProps.shrink !== 'undefined') { InputMore.notched = InputLabelProps.shrink; } - if (label ) { + if (label) { InputMore.label = ( {label} From e85ee2390e55e8c0c13caeb54dbbfd07e7dbf46c Mon Sep 17 00:00:00 2001 From: Serhii Date: Sun, 16 Feb 2020 14:57:10 +0100 Subject: [PATCH 07/10] test refactor --- packages/material-ui/src/TextField/TextField.test.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/material-ui/src/TextField/TextField.test.js b/packages/material-ui/src/TextField/TextField.test.js index f6a9d69ddf8541..1bd092dec87e83 100644 --- a/packages/material-ui/src/TextField/TextField.test.js +++ b/packages/material-ui/src/TextField/TextField.test.js @@ -62,15 +62,13 @@ describe('', () => { expect(container.querySelector('label')).to.have.class('foo'); }); - it('should not render empty label element', () => { - const { container } = render(); - expect(container.querySelector('label')).to.be.null; - }); - it('should not render undefined label element', () => { - const { container } = render(); + ['', undefined].forEach(label => { + it(`should not render empty - [${label}] label element`, () => { + const { container } = render(); - expect(container.querySelector('label')).to.be.null; + expect(container.querySelector('label')).to.be.null; + }); }); }); From 074575ccee4009b04ad6f662821bffa311e7e5cb Mon Sep 17 00:00:00 2001 From: Serhii Date: Sun, 16 Feb 2020 15:13:34 +0100 Subject: [PATCH 08/10] trigger pipeline --- packages/material-ui/src/TextField/TextField.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/material-ui/src/TextField/TextField.test.js b/packages/material-ui/src/TextField/TextField.test.js index 1bd092dec87e83..b10540112008f2 100644 --- a/packages/material-ui/src/TextField/TextField.test.js +++ b/packages/material-ui/src/TextField/TextField.test.js @@ -64,7 +64,7 @@ describe('', () => { }); ['', undefined].forEach(label => { - it(`should not render empty - [${label}] label element`, () => { + it(`should not render empty (${label}) label element`, () => { const { container } = render(); expect(container.querySelector('label')).to.be.null; From 3bf2a9368006fe84d0f9557eb8d4aec87b4bd62c Mon Sep 17 00:00:00 2001 From: Serhii Date: Wed, 19 Feb 2020 21:26:34 +0100 Subject: [PATCH 09/10] pipeline --- packages/material-ui/src/TextField/TextField.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/material-ui/src/TextField/TextField.js b/packages/material-ui/src/TextField/TextField.js index a93f2c288ad767..0d06332dc02524 100644 --- a/packages/material-ui/src/TextField/TextField.js +++ b/packages/material-ui/src/TextField/TextField.js @@ -109,7 +109,7 @@ const TextField = React.forwardRef(function TextField(props, ref) { if (label) { InputMore.label = ( - {label} + {label } {required && '\u00a0*'} ); From 66de6490f93b702da58d6fde3e5938859feb81a3 Mon Sep 17 00:00:00 2001 From: Serhii Date: Wed, 19 Feb 2020 21:27:00 +0100 Subject: [PATCH 10/10] prettier --- packages/material-ui/src/TextField/TextField.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/material-ui/src/TextField/TextField.js b/packages/material-ui/src/TextField/TextField.js index 0d06332dc02524..a93f2c288ad767 100644 --- a/packages/material-ui/src/TextField/TextField.js +++ b/packages/material-ui/src/TextField/TextField.js @@ -109,7 +109,7 @@ const TextField = React.forwardRef(function TextField(props, ref) { if (label) { InputMore.label = ( - {label } + {label} {required && '\u00a0*'} );