From 73690433babdc7e39396c9781dcf7e2eda94be1f Mon Sep 17 00:00:00 2001 From: Kieran Donegan Date: Thu, 17 Mar 2016 10:29:37 -0700 Subject: [PATCH] input does not render label if it does not exist Signed-off-by: Yucheng Tu --- library/spec/pivotal-ui-react/inputs/inputs_spec.js | 10 ++++++++++ library/src/pivotal-ui-react/inputs/inputs.js | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/library/spec/pivotal-ui-react/inputs/inputs_spec.js b/library/spec/pivotal-ui-react/inputs/inputs_spec.js index 8d3e81670..51c765983 100644 --- a/library/spec/pivotal-ui-react/inputs/inputs_spec.js +++ b/library/spec/pivotal-ui-react/inputs/inputs_spec.js @@ -34,6 +34,16 @@ describe('Input', function() { expect('.form-group').toHaveClass('input-class'); }); + describe('when label is undefined', () => { + beforeEach(() => { + subject::setProps({label: undefined}); + }); + + it('does not render label', () => { + expect('label').not.toExist(); + }); + }); + describe('Validation', function() { it('does not show error messages when displayError is false', function() { expect('.error-text').not.toExist(); diff --git a/library/src/pivotal-ui-react/inputs/inputs.js b/library/src/pivotal-ui-react/inputs/inputs.js index cc2aecd04..37d53a8af 100644 --- a/library/src/pivotal-ui-react/inputs/inputs.js +++ b/library/src/pivotal-ui-react/inputs/inputs.js @@ -34,7 +34,7 @@ class Input extends React.Component { const inputProps = mergeProps(props, {className: inputClassNames, 'aria-label': placeholder}) return (
- + {label && } {search && } {displayError &&