Skip to content

Commit 7c47808

Browse files
authored
fix(switch): prevent hover state change when disabled (#9365)
**Related Issue:** #7723 ## Summary Prevents interaction states on switch when disabled.
1 parent 90926c2 commit 7c47808

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export const CSS = {
2+
container: "container",
3+
track: "track",
4+
handle: "handle",
5+
};

packages/calcite-components/src/components/switch/switch.scss

+6-9
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
inset-inline: -1px theme("inset.auto");
8686
}
8787

88-
:host(:hover),
88+
.container:hover,
8989
:host(:focus) {
9090
.handle {
9191
@apply border-color-brand;
@@ -101,15 +101,12 @@
101101
@apply border-color-brand;
102102
inset-inline: theme("inset.auto") -1px;
103103
}
104-
}
105104

106-
:host([checked]:hover) {
107-
.track {
108-
@apply bg-brand border-color-brand-hover;
109-
}
110-
.handle {
111-
@apply border-color-brand-hover;
112-
box-shadow: inset 0 0 0 1px var(--calcite-color-brand-hover);
105+
.container:hover {
106+
.handle {
107+
@apply border-color-brand-hover;
108+
box-shadow: inset 0 0 0 1px var(--calcite-color-brand-hover);
109+
}
113110
}
114111
}
115112

packages/calcite-components/src/components/switch/switch.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
setUpLoadableComponent,
3333
} from "../../utils/loadable";
3434
import { Scale } from "../interfaces";
35+
import { CSS } from "./resources";
3536

3637
@Component({
3738
tag: "calcite-switch",
@@ -204,13 +205,13 @@ export class Switch
204205
<div
205206
aria-checked={toAriaBoolean(this.checked)}
206207
aria-label={getLabelText(this)}
207-
class="container"
208+
class={CSS.container}
208209
ref={this.setSwitchEl}
209210
role="switch"
210211
tabIndex={0}
211212
>
212-
<div class="track">
213-
<div class="handle" />
213+
<div class={CSS.track}>
214+
<div class={CSS.handle} />
214215
</div>
215216
<HiddenFormInputSlot component={this} />
216217
</div>

0 commit comments

Comments
 (0)