Skip to content

Commit 4819c5b

Browse files
crisbetojelbourn
authored andcommittedFeb 11, 2019
fix(checkbox): unable to click to select if text is marked (#15062)
Fixes not being able to select a checkbox button by clicking on it, if part of the text of the label is marked. Also fixes text inside the checkbox being marked if the user clicks on it quickly. Relates to #14967.
1 parent 3af7748 commit 4819c5b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
 

‎src/lib/checkbox/checkbox.scss

+12
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
@import '../core/style/checkbox-common';
44
@import '../core/ripple/ripple';
55
@import '../core/style/layout-common';
6+
@import '../core/style/vendor-prefixes';
67
@import '../core/style/noop-animation';
78
@import '../../cdk/a11y/a11y';
89

@@ -189,6 +190,11 @@ $_mat-checkbox-mark-stroke-size: 2 / 15 * $mat-checkbox-size !default;
189190
}
190191

191192
.mat-checkbox-layout {
193+
// Disable text selection on the label itself, because having text selected
194+
// will prevent focus from reaching the label. Below we'll re-enable it only
195+
// for the label's content so that people can still select the text.
196+
@include user-select(none);
197+
192198
// `cursor: inherit` ensures that the wrapper element gets the same cursor as the mat-checkbox
193199
// (e.g. pointer by default, regular when disabled), instead of the browser default.
194200
cursor: inherit;
@@ -198,6 +204,12 @@ $_mat-checkbox-mark-stroke-size: 2 / 15 * $mat-checkbox-size !default;
198204
white-space: nowrap;
199205
}
200206

207+
.mat-checkbox-label {
208+
// Re-enable text selection for the checkbox's content since
209+
// we disabled it above in the `.mat-checkbox-layout`.
210+
@include user-select(auto);
211+
}
212+
201213
.mat-checkbox-inner-container {
202214
display: inline-block;
203215
height: $mat-checkbox-size;

0 commit comments

Comments
 (0)
Please sign in to comment.