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

feat: add required, error message and helper text to checkbox #7285

Merged
merged 16 commits into from
Apr 10, 2024

Conversation

web-padawan
Copy link
Member

@web-padawan web-padawan commented Mar 28, 2024

Description

Fixes #938
Fixes #3749

Type of change

  • Feature

Note

This changes vaadin-checkbox to use FieldMixin which also adds accessibleName and accessibleNameRef.

@web-padawan web-padawan requested review from rolfsmeds and vursen March 28, 2024 09:56
@web-padawan web-padawan force-pushed the feat/checkbox-required-helper branch 3 times, most recently from 5efa7dc to 868fbc6 Compare March 28, 2024 11:31
@rolfsmeds
Copy link
Contributor

Currently, required indicator increases width of the vaadin-checkbox when it's shown (as it is placed after the label).
Trying to use position: absolute for it to keep width consistent causes issues when e.g. helper is longer than the label.

I presume you're referring to the indicator then ending up aligned with the helper's end, rather than the label's end?
But what if we set the width of the label part to max-content?

@web-padawan
Copy link
Member Author

But what if we set the width of the label part to max-content?

Yes, using max-width: max-content on the label part work with position: absolute on the indicator.
It would make the required indicator not extend width (but it will be placed close to the label text).

Screenshot 2024-04-03 at 15 10 12

@web-padawan web-padawan requested a review from rolfsmeds April 3, 2024 12:11
@rolfsmeds
Copy link
Contributor

But what if we set the width of the label part to max-content?

Yes, using max-width: max-content on the label part work with position: absolute on the indicator. It would make the required indicator not extend width (but it will be placed close to the label text).

Screenshot 2024-04-03 at 15 10 12

I suppose adding a bit of end-padding to the label would be good? max-content should take that into account IIRC.

@web-padawan
Copy link
Member Author

I suppose adding a bit of end-padding to the label would be good? max-content should take that into account IIRC.

Yes, it already has padding end set to --lumo-space-s on ::slotted(label). Increasing it to --lumo-space-m would help to make indicator look not too close to the checkbox. But that would also increase the default checkbox width.

@web-padawan web-padawan removed the request for review from vursen April 4, 2024 08:26
Comment on lines +46 to +52
:host([dir='rtl'][has-label]) ::slotted(label) {
padding: var(--lumo-space-xs) var(--lumo-space-xs) var(--lumo-space-xs) var(--lumo-space-s);
}

:host([has-label][required]) ::slotted(label) {
padding-inline-end: var(--lumo-space-m);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved RTL style block to make sure required state overrides padding for it.

@web-padawan web-padawan requested a review from sissbruecker April 4, 2024 10:35
@web-padawan web-padawan force-pushed the feat/checkbox-required-helper branch from 2d158f6 to 14d2000 Compare April 10, 2024 09:59
@@ -61,6 +61,7 @@ export interface CheckboxGroupEventMap extends HTMLElementEventMap, CheckboxGrou
* Attribute | Description | Part name
* --------------------|-------------------------------------------|------------
* `disabled` | Set when the element is disabled | :host
* `readonly` | Set when the element is readonly | :host
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed to include this change to #7199 🙈

@web-padawan web-padawan removed the request for review from sissbruecker April 10, 2024 10:12
@web-padawan web-padawan force-pushed the feat/checkbox-required-helper branch from 7aa942f to d394916 Compare April 10, 2024 10:31
@web-padawan web-padawan force-pushed the feat/checkbox-required-helper branch from d394916 to 1f2ac02 Compare April 10, 2024 10:39
Copy link

Quality Gate Passed Quality Gate passed

Issues
1 New issue
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@web-padawan web-padawan merged commit 992a3a2 into main Apr 10, 2024
9 checks passed
@web-padawan web-padawan deleted the feat/checkbox-required-helper branch April 10, 2024 10:53
@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with Vaadin 24.4.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[checkbox] Add helper support [checkbox] Add required property
5 participants