Repository navigation
fix: make empty space next to checkbox label clickable - #13381
Conversation
The hover styles of checkbox and switch cover the whole component, but only clicks on the input, the label text or the required indicator toggled the checked state. Clicking the empty space next to the label, e.g. in a full-width checkbox, showed the hover style but did nothing. Clicks on any element in the shadow DOM, except the helper text and error message, now toggle the checked state, like the required indicator already did. Clicks targeting the host itself are ignored, so that synthetic clicks dispatched to the host (e.g. by the grid on Space key) do not toggle it.
Limit the clickable empty space to the label part and the container element, which is the empty space next to the label in Lumo, instead of excluding helper text and error message from the whole shadow DOM.
A real mouse click on the empty space moves the starting point of sequential focus navigation in WebKit, so the following Space key tests no longer reached the input with Tab.
web-padawan
left a comment
There was a problem hiding this comment.
🤖 AI-generated
Reviewed 9498a15 and left 2 comments: 1 issue, 1 nitpick.
In Lumo the container element spans all rows, so clicks next to the helper text or error message also hit it. Only treat container clicks within the vertical bounds of the label part as clicks on the empty space next to the label.
ActiveMixin calls _shouldSetActive with a gesture event that has the coordinates in detail instead of clientY, so container mousedown in the label row did not set the active attribute.
|
🤖 AI-generated suggestion (design, non-blocking): The fix can be CSS only: let the visually hidden
Sketch for :host {
position: relative;
}
::slotted(input) {
position: absolute;
/* An absolute grid item needs an explicit end line, or it also covers the helper rows */
grid-row: 1 / 2;
grid-column: 1 / -1;
/* Ensure minimum click target (WCAG) */
inset-block: min(0px, (100% - 24px) / 2);
inset-inline: min(0px, (100% - 24px) / 2);
margin: 0 !important;
width: auto !important;
height: auto !important;
}
/* Let clicks next to the label text and on the required indicator reach the input */
[part='label'] {
pointer-events: none;
}
[part='label'] ::slotted(*) {
pointer-events: auto;
}The old input margins and the I checked a prototype with real mouse clicks in Chromium, Firefox and WebKit with base styles and Lumo, and on the "Bells & Whistles" checkboxes of
Trade-offs: the input box, and so the screen reader highlight, now covers the label row. The host gets |
…icks Let the visually hidden input cover the whole first row of checkbox, radio button and switch, and let clicks pass through the label part. Clicks on the empty space next to the label and on the required indicator now reach the input natively, so the JS click forwarding and the required indicator click handler are no longer needed. The helper text and error message rows are not covered.
|
@web-padawan Thanks, switched to the CSS-only approach. The input is absolutely positioned over the first row in I checked checkbox, switch and radio button with base styles, Lumo and Aura (default, required, helper text, |
The checkable-field mixin sets pointer-events: auto on the slotted label, which overrode pointer-events: none of the disabled host in Lumo.
|
note: with the CSS only fix, hover styles for Lumo are still shown when mouse moves over the helper text / error message, but clicking doesn't toggle the checked state, as expected. Not sure if it can be easily fixed. |
|
@web-padawan Good catch. I don't see a simple CSS fix inside Lumo's shadow styles:
The remaining options are a JS-reflected hover attribute, or limiting the Lumo hover style to the label row in a follow-up. I've left this PR as is, so it only fixes the click target. Happy to open a follow-up issue if you'd like that changed. |
|
Slide deck that explains this pull request from its code. Generated 2026-11-10 14:35 UTC |
vaadin-review-bot
left a comment
There was a problem hiding this comment.
Reviewed the changes — left 2 comments.
Risk: 🔴 high — It rewrites the hit area and pointer-event handling of checkbox, radio button and switch in both the shared base styles and the Lumo mixin, so every consumer's most-used form control changes interaction behavior, and one verified case lets labels stay clickable behind a modal overlay.
| Finding | |
|---|---|
pointer-events: auto on the slotted label makes labels clickable through an ancestor that disables pointer events, including the page behind a modal overlay |
|
| 🧪 | No test asserts that clicking the empty space actually toggles checked |
…ter events Setting pointer-events: auto on the slotted label made it clickable when an ancestor sets pointer-events: none, such as the body while a modal overlay is open. Instead, keep the label part hit-testable and size it to its content, so that only the empty space next to it reaches the input. The required indicator keeps its click handler.
|
|
This ticket/PR has been released with Vaadin 25.4.0-alpha7. |



Summary
Fixes vaadin/flow-components#6699
The hover styles of
vaadin-checkboxandvaadin-switchcover the whole component, but only clicks on the input, the label text or the required indicator toggled the checked state. In a checkbox wider than its label (e.g.width: 100%), clicking the empty space next to the label showed the hover style but did nothing. In Vaadin 23 the slotted label stretched over that space, so the click toggled the checkbox.What changed
<input>now covers the whole first row (the row with the control and the label) of checkbox, switch and radio button, in the base styles and in the Lumocheckable-fieldmixin. Clicks on the empty space next to the label reach the input natively, so they toggle the checked state and fire a singleclickevent.labelpart is sized to its content (justify-self: start) and stays above the input, so the label text, links in it and the required indicator work as before. Nopointer-eventsrules are added, so an ancestor withpointer-events: none(e.g. the body while a modal overlay is open) still blocks clicks on the label.position: relative. Thelabelpart box no longer stretches over the empty space, so::part(label):hoverdoes not match there.Type of change
Test summary
active, togglescheckedand fires oneclickevent.reversetheme) is covered by the input, and that the label, a link in it and the helper text row are not. Covered for base styles, for checkbox, switch and radio button.reversetheme.reversetheme, RTL, wrapped labels and no label, in Chromium, Firefox and WebKit (Lumo and Aura checked by hand). Part positions are unchanged compared tomain.Working on behalf of
@Legioth