Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Radio and InputGroup in horizontal FormLayout in Chrome and Edge (#493) #498

Merged
merged 2 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/components/FormLayout/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,10 @@ React.createElement(() => {
options={options}
value={fruit}
/>
<InputGroup label="Promo code">
<TextField label="Code" />
<Button label="Apply" color="secondary" priority="outline" />
</InputGroup>
</FormLayout>
</div>
)
Expand Down
2 changes: 1 addition & 1 deletion src/components/InputGroup/InputGroup.scss
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
}

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

// Sizes
Expand Down
2 changes: 1 addition & 1 deletion src/components/Radio/Radio.scss
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,5 @@
}

.isRootInFormLayout {
@include box-field-layout.in-form-layout();
@include box-field-layout.in-form-layout($is-fieldset: true);
}
40 changes: 26 additions & 14 deletions src/styles/tools/form-fields/_box-field-layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@
// Reverted for full-width fields.
//
// 8. Grid settings are inherited from horizontal FormLayout and applied using `subgrid`.
// A fallback is supplied to browsers that don't support `subgrid` yet. See FormLayout styles
// for more.
// A fallback is supplied to browsers that don't support `subgrid` yet.
//
// Chrome 117+ supports `subgrid` but it doesn't work for `<fieldset>`. This is why we always
// use the fallback for `<fieldset>`.
//
// https://bugs.chromium.org/p/chromium/issues/detail?id=1473242
// https://github.com/react-ui-org/react-ui/issues/232
//
// 9. Help texts and validation messages can take up full width of FormLayout. There is no reason
Expand Down Expand Up @@ -180,7 +184,7 @@
}
}

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

.field {
Expand All @@ -192,19 +196,27 @@
width: auto; // 11.
}

&.isRootLayoutHorizontal,
&.isRootLayoutHorizontal.hasRootSmallInput {
grid: inherit; // 8.
grid-template-columns: subgrid; // 8.
grid-column: span 2; // 8.

@supports not (grid-template-columns: subgrid) {
display: contents; // 8.
// 8.
@if $is-fieldset {
&.isRootLayoutHorizontal,
&.isRootLayoutHorizontal.hasRootSmallInput {
display: contents;
}
} @else {
&.isRootLayoutHorizontal,
&.isRootLayoutHorizontal.hasRootSmallInput {
grid: inherit;
grid-template-columns: subgrid;
grid-column: span 2;

@supports not (grid-template-columns: subgrid) {
display: contents;
}
}
}

&.isRootLayoutHorizontal.isRootFullWidth {
grid-template-columns: subgrid; // 8.
&.isRootLayoutHorizontal.isRootFullWidth {
grid-template-columns: subgrid;
}
}

&.isRootLayoutHorizontal .label,
Expand Down