Skip to content

Commit

Permalink
fix: do not show required indicator when checkbox has no label (#8294) (
Browse files Browse the repository at this point in the history
#8296)

Co-authored-by: Serhii Kulykov <iamkulykov@gmail.com>
  • Loading branch information
vaadin-bot and web-padawan authored Dec 7, 2024
1 parent 27dbb99 commit 059142a
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/checkbox/test/visual/lumo/checkbox.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ describe('checkbox', () => {
await visualDiff(div, 'required');
});

it('required empty', async () => {
element.required = true;
element.label = '';
await visualDiff(div, 'required-empty');
});

it('invalid focus-ring', async () => {
element.required = true;
element.invalid = true;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions packages/checkbox/test/visual/material/checkbox.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ describe('checkbox', () => {
await visualDiff(div, 'required');
});

it('required empty', async () => {
element.required = true;
element.label = '';
await visualDiff(div, 'required-empty');
});

it('error message', async () => {
element.errorMessage = 'This field is required';
element.required = true;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions packages/checkbox/theme/lumo/vaadin-checkbox-styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,10 @@ registerStyles(
text-align: center;
}
:host(:not([has-label])) [part='required-indicator'] {
display: none;
}
/* Invalid */
:host([invalid]) {
--vaadin-input-field-border-color: var(--lumo-error-color);
Expand Down
4 changes: 4 additions & 0 deletions packages/checkbox/theme/material/vaadin-checkbox-styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ registerStyles(
color: var(--material-error-text-color);
}
:host(:not([has-label])) [part='required-indicator'] {
display: none;
}
[part='error-message'],
[part='helper-text'] {
font-size: 0.75em;
Expand Down

0 comments on commit 059142a

Please sign in to comment.