Skip to content

Commit

Permalink
🐛 [open-formulieren/open-forms#3577] Fix overflow issue because of du…
Browse files Browse the repository at this point in the history
…plicated error styles

Suppress the formio styles alltogether and apply more NL DS styles
for a more consistent look.

The explicit width: 100% declarations are removed as they cause
overflows due to box-sizing rules, but the behaviour without
setting these appears to be correct in our and other's themes.
  • Loading branch information
sergei-maertens committed Nov 8, 2023
1 parent c5efbdf commit e0050c8
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 9 deletions.
54 changes: 53 additions & 1 deletion src/formio/components/Select.stories.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import {userEvent, within} from '@storybook/testing-library';

import {withUtrechtDocument} from 'story-utils/decorators';
import {sleep} from 'utils';

import {SingleFormioComponent} from './story-util';
import {MultipleFormioComponents, SingleFormioComponent} from './story-util';

export default {
title: 'Form.io components / Vanilla / Select',
Expand Down Expand Up @@ -49,3 +52,52 @@ export const Select = {
label: 'Welke optie is het meest onduidelijk?',
},
};

export const RequiredWithValidationError = {
render: MultipleFormioComponents,
args: {
components: [
{
type: 'select',
key: 'selectRequired',
label: 'Required select',
data: {
values: [
{
label: 'Optie A',
value: 'radioA',
},
{
label: 'Optie B',
value: 'radioB',
},
{
label: 'Optie C',
value: 'radioC',
},
],
},
validate: {
required: true,
},
},
{
label: 'Check validations',
showValidations: true,
key: 'submit1',
type: 'button',
input: true,
action: 'notSubmit',
},
],
},

play: async ({canvasElement}) => {
const canvas = within(canvasElement);

// just form.io things...
await sleep(100);

await userEvent.click(canvas.getByRole('button'));
},
};
34 changes: 26 additions & 8 deletions src/scss/components/_deprecated-select.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,44 @@ $select-background-color: var(--of-select-background-color, $color-white);
$item-hpadding: $grid-margin-1;
$vborders: $typography-size-border;

width: 100%;

// The wrapper div.
// Style as a regular input.
.choices {
@include body;
@include border(all, $size: 1px);
@include rows(1, min-height);

position: relative;
display: flex;
align-items: center;

background-color: var(
--utrecht-select-background-color,
var(--utrecht-form-control-background-color, var(--of-color-bg))
);
border-bottom-width: var(--utrecht-select-border-bottom-width, 1px);
border-color: var(--utrecht-select-border-color, var(--of-field-border-color));
border-radius: 0;
border-style: solid;
border-width: var(--utrecht-select-border-width, 1px);

font-weight: bold;
padding: 0 $list-hpadding;
width: 100%;

max-inline-size: calc(
var(--utrecht-select-max-inline-size, var(--utrecht-form-control-max-inline-size)) - 2 * #{$list-hpadding}
);

.choices__list {
background-color: var(--of-color-bg);
border-color: var(--of-field-border-color);
color: var(--of-color-fg);
background-color: var(
--utrecht-select-background-color,
var(--utrecht-form-control-background-color, var(--of-color-bg))
);
border-color: var(--utrecht-select-border-color, var(--of-field-border-color));
color: var(--utrecht-select-color, var(--of-color-fg));
max-inline-size: var(
--utrecht-select-max-inline-size,
var(--utrecht-form-control-max-inline-size)
);

.is-highlighted {
background-color: var(--of-select-highlighted-bg);
Expand Down Expand Up @@ -93,7 +111,7 @@ $select-background-color: var(--of-select-background-color, $color-white);

// Available choices.
.selection + .choices__list {
left: 0;
left: -1px; // border width
}

// Items within the available choices.
Expand Down
6 changes: 6 additions & 0 deletions src/scss/components/_errors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@
}
}
}

// the formio styles conflict with our NL DS components, applying double padding and
// causing overflows, so we reset them.
.formio-error-wrapper {
all: revert;
}

0 comments on commit e0050c8

Please sign in to comment.