Skip to content

Commit c90e312

Browse files
committed
Add missing :disabled styles for checkbox/radio button buttons
1 parent 8bc5e96 commit c90e312

File tree

2 files changed

+53
-8
lines changed

2 files changed

+53
-8
lines changed

scss/_buttons.scss

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,25 @@ input[type="button"] {
156156
+ .btn {
157157
margin-bottom: 0; // Override default `<label>` value
158158
}
159+
160+
&:focus + .btn {
161+
outline: 0;
162+
box-shadow: $btn-focus-box-shadow;
163+
}
164+
165+
// Disabled comes first so active can properly restyle
166+
&:disabled + .btn {
167+
opacity: $btn-disabled-opacity;
168+
@include box-shadow(none);
169+
}
170+
171+
&:not(:disabled):active + .btn {
172+
@include box-shadow($btn-active-box-shadow);
173+
}
174+
175+
&:not(:disabled):active:focus + .btn {
176+
@include box-shadow($btn-focus-box-shadow, $btn-active-box-shadow);
177+
}
159178
}
160179

161180
// Make the button input wrapper behave like a button

scss/mixins/_buttons.scss

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
&:focus,
2020
&.focus,
2121
.btn-input:focus + &,
22-
.btn-input:active + & {
22+
.btn-input:not(:disabled):active + & {
2323
color: color-yiq($hover-background);
2424
@include gradient-bg($hover-background);
2525
border-color: $hover-border;
@@ -33,7 +33,8 @@
3333

3434
// Disabled comes first so active can properly restyle
3535
&.disabled,
36-
&:disabled {
36+
&:disabled,
37+
.btn-input:disabled + & {
3738
color: color-yiq($background);
3839
background-color: $background;
3940
border-color: $border;
@@ -45,8 +46,8 @@
4546

4647
&:not(:disabled):not(.disabled):active,
4748
&:not(:disabled):not(.disabled).active,
48-
.btn-input:checked + &,
49-
.btn-input:active + &,
49+
.btn-input:not(:disabled):checked + &,
50+
.btn-input:not(:disabled):active + &,
5051
.show > &.dropdown-toggle {
5152
color: color-yiq($active-background);
5253
background-color: $active-background;
@@ -64,6 +65,20 @@
6465
}
6566
}
6667
}
68+
69+
// Duplicate the disabled styles again specifically to
70+
// override the previous :active styles, as button-like
71+
// checkbox/radio buttons can't be excluded generically
72+
// from the previous set of selectors
73+
.btn-input:disabled + &:active {
74+
color: color-yiq($background);
75+
background-color: $background;
76+
border-color: $border;
77+
// Remove CSS gradients if they're enabled
78+
@if $enable-gradients {
79+
background-image: none;
80+
}
81+
}
6782
}
6883

6984
@mixin button-outline-variant($color, $color-hover: color-yiq($color), $active-background: $color, $active-border: $color) {
@@ -80,20 +95,22 @@
8095
&:focus,
8196
&.focus,
8297
.btn-input:focus + &,
83-
.btn-input:active + & {
98+
.btn-input:not(:disabled):active + & {
8499
box-shadow: 0 0 0 $btn-focus-width rgba($color, .5);
85100
}
86101

87102
&.disabled,
88-
&:disabled {
103+
&:disabled,
104+
.btn-input:disabled + &,
105+
.btn-input:not(:disabled) + &:active {
89106
color: $color;
90107
background-color: transparent;
91108
}
92109

93110
&:not(:disabled):not(.disabled):active,
94111
&:not(:disabled):not(.disabled).active,
95-
.btn-input:checked + &,
96-
.btn-input:active + &,
112+
.btn-input:not(:disabled):checked + &,
113+
.btn-input:not(:disabled):active + &,
97114
.show > &.dropdown-toggle {
98115
color: color-yiq($active-background);
99116
background-color: $active-background;
@@ -108,6 +125,15 @@
108125
}
109126
}
110127
}
128+
129+
// Duplicate the disabled styles again specifically to
130+
// override the previous :active styles, as button-like
131+
// checkbox/radio buttons can't be excluded generically
132+
// from the previous set of selectors
133+
.btn-input:disabled + &:active {
134+
color: $color;
135+
background-color: transparent;
136+
}
111137
}
112138

113139
// Button sizes

0 commit comments

Comments
 (0)