Skip to content

Commit

Permalink
fix(sbb-form-field): fix disabled state for borderless variant (#2994)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeripeierSBB authored Aug 8, 2024
1 parent b1e2633 commit c31cc89
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/elements/form-field/form-field/form-field.scss
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
}
}

:host(:is([data-input-focused], [data-has-popup-open])[borderless]) & {
:host(:is([data-input-focused], [data-has-popup-open], [data-disabled])[borderless]) & {
&::after {
content: '';
position: absolute;
Expand Down
88 changes: 64 additions & 24 deletions src/elements/form-field/form-field/form-field.visual.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ describe(`sbb-form-field`, () => {
visualDiffState.with(async (setup) => {
await setup.withFixture(html`${formField(args, template(args))}`, {
backgroundColor: negative ? 'var(--sbb-color-black)' : undefined,
focusOutlineDark: negative,
forcedColors,
});
}),
Expand All @@ -185,6 +186,7 @@ describe(`sbb-form-field`, () => {
const templateResult: TemplateResult = html`${template(args)} ${icons}`;
await setup.withFixture(html`${formField(args, templateResult)}`, {
backgroundColor: negative ? 'var(--sbb-color-black)' : undefined,
focusOutlineDark: negative,
forcedColors,
});
}),
Expand All @@ -198,6 +200,7 @@ describe(`sbb-form-field`, () => {
${buttonsAndPopover(args)}`;
await setup.withFixture(html`${formField(args, templateResult)}`, {
backgroundColor: negative ? 'var(--sbb-color-black)' : undefined,
focusOutlineDark: negative,
forcedColors,
});
}),
Expand All @@ -210,6 +213,7 @@ describe(`sbb-form-field`, () => {
${buttonsAndPopover(args)}`;
await setup.withFixture(html`${formField(args, templateResult)}`, {
backgroundColor: negative ? 'var(--sbb-color-black)' : undefined,
focusOutlineDark: negative,
forcedColors,
});
}),
Expand All @@ -222,6 +226,7 @@ describe(`sbb-form-field`, () => {
${buttonsAndPopover(args)}`;
await setup.withFixture(html`${formField(args, templateResult)}`, {
backgroundColor: negative ? 'var(--sbb-color-black)' : undefined,
focusOutlineDark: negative,
forcedColors,
});
(
Expand All @@ -248,6 +253,7 @@ describe(`sbb-form-field`, () => {
visualDiffDefault.with(async (setup) => {
await setup.withFixture(html`${formField(args, template(args))}`, {
backgroundColor: negative ? 'var(--sbb-color-black)' : undefined,
focusOutlineDark: negative,
forcedColors,
});
}),
Expand All @@ -260,6 +266,7 @@ describe(`sbb-form-field`, () => {
${buttonsAndPopover(args)}`;
await setup.withFixture(html`${formField(args, templateResult)}`, {
backgroundColor: negative ? 'var(--sbb-color-black)' : undefined,
focusOutlineDark: negative,
forcedColors,
});
}),
Expand Down Expand Up @@ -337,31 +344,64 @@ describe(`sbb-form-field`, () => {
);

// borderless
for (const negative of [false, true]) {
describe(`negative=${negative}`, () => {
it(
`borderless=true`,
visualDiffDefault.with(async (setup) => {
const noLabel = { ...basicArgs, negative, borderless: true };
await setup.withFixture(html`${formField(noLabel, template(noLabel))}`, {
backgroundColor: negative ? 'var(--sbb-color-black)' : undefined,
forcedColors,
});
}),
);
describe('borderless=true', () => {
for (const negative of [false, true]) {
describe(`negative=${negative}`, () => {
it(
``,
visualDiffDefault.with(async (setup) => {
const noLabel = { ...basicArgs, negative, borderless: true };
await setup.withFixture(html`${formField(noLabel, template(noLabel))}`, {
backgroundColor: negative ? 'var(--sbb-color-black)' : undefined,
focusOutlineDark: negative,
forcedColors,
});
}),
);

it(
`borderless=true ${visualDiffFocus.name}`,
visualDiffFocus.with(async (setup) => {
const noLabel = { ...basicArgs, negative, borderless: true };
await setup.withFixture(html`${formField(noLabel, template(noLabel))}`, {
backgroundColor: negative ? 'var(--sbb-color-black)' : undefined,
forcedColors,
});
}),
);
});
}
it(
`disabled=true`,
visualDiffDefault.with(async (setup) => {
const noLabel = { ...basicArgs, negative, borderless: true, disabled: true };
await setup.withFixture(html`${formField(noLabel, template(noLabel))}`, {
backgroundColor: negative ? 'var(--sbb-color-black)' : undefined,
focusOutlineDark: negative,
forcedColors,
});
}),
);

it(
`error=true ${visualDiffFocus.name}`,
visualDiffFocus.with(async (setup) => {
const noLabel = {
...basicArgs,
negative,
borderless: true,
cssClass: 'sbb-invalid',
};
await setup.withFixture(html`${formField(noLabel, template(noLabel))}`, {
backgroundColor: negative ? 'var(--sbb-color-black)' : undefined,
focusOutlineDark: negative,
forcedColors,
});
}),
);

it(
visualDiffFocus.name,
visualDiffFocus.with(async (setup) => {
const noLabel = { ...basicArgs, negative, borderless: true };
await setup.withFixture(html`${formField(noLabel, template(noLabel))}`, {
backgroundColor: negative ? 'var(--sbb-color-black)' : undefined,
focusOutlineDark: negative,
forcedColors,
});
}),
);
});
}
});

// visual
describeEach(visualProp, ({ size, width, errorText }) => {
Expand Down

0 comments on commit c31cc89

Please sign in to comment.