Skip to content

fix(switch): prevent hover state change when disabled #9365

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

Merged
merged 1 commit into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const CSS = {
container: "container",
track: "track",
handle: "handle",
};
15 changes: 6 additions & 9 deletions packages/calcite-components/src/components/switch/switch.scss
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
inset-inline: -1px theme("inset.auto");
}

:host(:hover),
.container:hover,
:host(:focus) {
.handle {
@apply border-color-brand;
Expand All @@ -101,15 +101,12 @@
@apply border-color-brand;
inset-inline: theme("inset.auto") -1px;
}
}

:host([checked]:hover) {
.track {
@apply bg-brand border-color-brand-hover;
}
.handle {
@apply border-color-brand-hover;
box-shadow: inset 0 0 0 1px var(--calcite-color-brand-hover);
.container:hover {
.handle {
@apply border-color-brand-hover;
box-shadow: inset 0 0 0 1px var(--calcite-color-brand-hover);
}
}
}

Expand Down
7 changes: 4 additions & 3 deletions packages/calcite-components/src/components/switch/switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
setUpLoadableComponent,
} from "../../utils/loadable";
import { Scale } from "../interfaces";
import { CSS } from "./resources";

@Component({
tag: "calcite-switch",
Expand Down Expand Up @@ -204,13 +205,13 @@ export class Switch
<div
aria-checked={toAriaBoolean(this.checked)}
aria-label={getLabelText(this)}
class="container"
class={CSS.container}
ref={this.setSwitchEl}
role="switch"
tabIndex={0}
>
<div class="track">
<div class="handle" />
<div class={CSS.track}>
<div class={CSS.handle} />
</div>
<HiddenFormInputSlot component={this} />
</div>
Expand Down
Loading