Skip to content

Commit b25093b

Browse files
committed
Fix Radio and InputGroup in horizontal FormLayout in Chrome and Edge (#493)
Subgrid is now supported in all major browsers including Chrome and Edge joining as last in August's version 117. However, there is some fieldset/legend magic that prevents subgrid from being used on `<fieldset>` element (as per the spec (sic!), the magic adds an additional virtual box which breaks the subgrid). As a result, subgrid cannot be used on `<fieldset>` elements until the following Chromium issue is resolved: https://bugs.chromium.org/p/chromium/issues/detail?id=1473242 (cherry picked from commit 26cacd3)
1 parent 2c45e31 commit b25093b

File tree

3 files changed

+28
-16
lines changed

3 files changed

+28
-16
lines changed

src/lib/components/InputGroup/InputGroup.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
}
7676

7777
.isRootInFormLayout {
78-
@include box-field-layout.in-form-layout();
78+
@include box-field-layout.in-form-layout($is-fieldset: true);
7979
}
8080

8181
// Sizes

src/lib/components/Radio/Radio.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,5 @@
8484
}
8585

8686
.isRootInFormLayout {
87-
@include box-field-layout.in-form-layout();
87+
@include box-field-layout.in-form-layout($is-fieldset: true);
8888
}

src/lib/styles/tools/form-fields/_box-field-layout.scss

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@
2626
// Reverted for full-width fields.
2727
//
2828
// 8. Grid settings are inherited from horizontal FormLayout and applied using `subgrid`.
29-
// A fallback is supplied to browsers that don't support `subgrid` yet. See FormLayout styles
30-
// for more.
29+
// A fallback is supplied to browsers that don't support `subgrid` yet.
30+
//
31+
// Chrome 117+ supports `subgrid` but it doesn't work for `<fieldset>`. This is why we always
32+
// use the fallback for `<fieldset>`.
33+
//
34+
// https://bugs.chromium.org/p/chromium/issues/detail?id=1473242
3135
// https://github.com/react-ui-org/react-ui/issues/232
3236
//
3337
// 9. Help texts and validation messages can take up full width of FormLayout. There is no reason
@@ -180,7 +184,7 @@
180184
}
181185
}
182186

183-
@mixin in-form-layout() {
187+
@mixin in-form-layout($is-fieldset: false) {
184188
justify-self: start; // 12.
185189

186190
.field {
@@ -192,19 +196,27 @@
192196
width: auto; // 11.
193197
}
194198

195-
&.isRootLayoutHorizontal,
196-
&.isRootLayoutHorizontal.hasRootSmallInput {
197-
grid: inherit; // 8.
198-
grid-template-columns: subgrid; // 8.
199-
grid-column: span 2; // 8.
200-
201-
@supports not (grid-template-columns: subgrid) {
202-
display: contents; // 8.
199+
// 8.
200+
@if $is-fieldset {
201+
&.isRootLayoutHorizontal,
202+
&.isRootLayoutHorizontal.hasRootSmallInput {
203+
display: contents;
204+
}
205+
} @else {
206+
&.isRootLayoutHorizontal,
207+
&.isRootLayoutHorizontal.hasRootSmallInput {
208+
grid: inherit;
209+
grid-template-columns: subgrid;
210+
grid-column: span 2;
211+
212+
@supports not (grid-template-columns: subgrid) {
213+
display: contents;
214+
}
203215
}
204-
}
205216

206-
&.isRootLayoutHorizontal.isRootFullWidth {
207-
grid-template-columns: subgrid; // 8.
217+
&.isRootLayoutHorizontal.isRootFullWidth {
218+
grid-template-columns: subgrid;
219+
}
208220
}
209221

210222
&.isRootLayoutHorizontal .label,

0 commit comments

Comments
 (0)