Skip to content

Commit bfe16ea

Browse files
committed
refactor(ui-form-field): fix wrong bottom margin when layout is inline
Also correct the margin between controls and messages in DateTimeInput
1 parent 502449d commit bfe16ea

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

packages/ui-form-field/src/FormFieldLayout/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,11 @@ class FormFieldLayout extends Component<FormFieldLayoutProps> {
154154
)
155155
}
156156
// needs to be wrapped because it needs an `id`
157-
return <div id={this._labelId}>{this.props.label}</div>
157+
return (
158+
<div id={this._labelId} style={{ display: 'contents' }}>
159+
{this.props.label}
160+
</div>
161+
)
158162
} else return null
159163
}
160164

packages/ui-form-field/src/FormFieldLayout/styles.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ const generateStyle = (
102102
fontWeight: componentTheme.fontWeight,
103103
fontSize: componentTheme.fontSize,
104104
lineHeight: componentTheme.lineHeight,
105-
margin: '0 0 0.75rem 0',
106105
...(isInlineLayout && {
106+
margin: '0',
107107
// when inline add a small padding between the label and the control
108108
paddingRight: componentTheme.inlinePadding,
109109
// and use the horizontal alignment prop
@@ -150,6 +150,7 @@ const generateStyle = (
150150
)
151151
},
152152
columnGap: '0.375rem',
153+
rowGap: '0.75rem',
153154
width: '100%',
154155
...(inline && {
155156
display: 'inline-grid',
@@ -158,20 +159,16 @@ const generateStyle = (
158159
},
159160
formFieldLabel: {
160161
label: 'formFieldLayout__label',
161-
...(hasVisibleLabel && {
162-
...labelStyles,
163-
// NOTE: needs separate groups for `:is()` and `:-webkit-any()` because of css selector group validation (see https://www.w3.org/TR/selectors-3/#grouping)
164-
'&:is(label)': labelStyles,
165-
'&:-webkit-any(label)': labelStyles
166-
})
162+
...labelStyles,
163+
// NOTE: needs separate groups for `:is()` and `:-webkit-any()` because of css selector group validation (see https://www.w3.org/TR/selectors-3/#grouping)
164+
'&:is(label)': labelStyles,
165+
'&:-webkit-any(label)': labelStyles
167166
},
168167
formFieldChildren: {
169168
label: 'formFieldLayout__children',
170169
gridArea: 'controls',
171170
// add a small margin between the message and the controls
172171
...(hasMessages && hasNewErrorMsgAndIsGroup && { marginTop: '0.375rem' }),
173-
...(hasMessages &&
174-
!hasNewErrorMsgAndIsGroup && { marginBottom: '0.75rem' }),
175172
...(isInlineLayout &&
176173
inline && {
177174
[`@media screen and (min-width: ${componentTheme.stackedOrInlineBreakpoint})`]:

0 commit comments

Comments
 (0)