Skip to content

Commit

Permalink
fixed the height issues due to empty content [#153268701]
Browse files Browse the repository at this point in the history
Signed-off-by: Stephane Jolicoeur <sjolicoeur@pivotal.io>
  • Loading branch information
reidmit authored and apps-manager committed Nov 30, 2017
1 parent a58c1b8 commit e9a067b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
14 changes: 14 additions & 0 deletions spec/pivotal-ui-react/form/form-unit_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ describe('FormUnit', () => {
expect('.form-unit .label-row').not.toExist();
});

describe('when no field is provided', () => {
beforeEach(() => {
subject = ReactDOM.render(<FormUnit {...{
className: 'my-class',
label: 'some label'
}} />, root);
});

it('does not render a field row', () => {
expect('.form-unit .field-row').not.toExist();
});
});


describe('inline', () => {
beforeEach(() => {
subject::setProps({inline: true, label: 'Instance Name'});
Expand Down
10 changes: 8 additions & 2 deletions src/css/forms/forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -459,14 +459,20 @@ textarea.valid {

.label-row {
display: block;
line-height: 4 * $base-unit - 4;
line-height: 4 * $base-unit;
min-height: 4 * $base-unit;
font-weight: 600;
font-size: 14px;
}

.field-row {
min-height: 32px;
display: flex;
align-items: center;
}

.help-row {
line-height: 2 * $base-unit - 4;
line-height: 2 * $base-unit;
min-height: 2 * $base-unit;
font-weight: 400;
font-size: 12px;
Expand Down
2 changes: 1 addition & 1 deletion src/react/forms/form-unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class FormUnit extends React.Component {
</label>
);

const fieldRow = <div className="field-row" key="field-row">{field}</div>;
const fieldRow = field && <div className="field-row" key="field-row">{field}</div>;
const helpRow = hideHelpRow || <div className={classnames('help-row', {'type-dark-5': !hasError})}>{help}</div>;

const sections = labelPosition === 'after' ? [fieldRow, labelRow] : [labelRow, fieldRow];
Expand Down

0 comments on commit e9a067b

Please sign in to comment.