Skip to content
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

fix(switch): Fix for focus outline style in certain cases #7414

Merged
merged 2 commits into from
Aug 1, 2023
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
19 changes: 6 additions & 13 deletions packages/calcite-components/src/components/switch/switch.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,8 @@

@include disabled();

// focus styles
:host {
@apply focus-base w-auto;
}

.container {
@apply rounded-full;
@apply outline-0;
}

.track {
Expand All @@ -67,9 +62,11 @@
border
border-solid
align-top
transition-all
duration-150
ease-in-out;
focus-base;
}

:host(:focus) .track {
@apply focus-outset;
}

.handle {
Expand Down Expand Up @@ -124,9 +121,5 @@
}
}

.container:focus {
@apply focus-outset;
}

@include hidden-form-input();
@include base-component();
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const disabled_TestOnly = (): string => html`<calcite-switch disabled che
export const Focus_TestOnly = (): string =>
html`
<div style="width:300px;height:300px; padding: 20px">
<calcite-switch> </calcite-switch>
<calcite-switch></calcite-switch>
</div>
<script>
(async () => {
Expand All @@ -52,3 +52,20 @@ export const Focus_TestOnly = (): string =>
Focus_TestOnly.parameters = {
chromatic: { delay: 1000 },
};

export const FocusLabel_TestOnly = (): string =>
html`
<div style="width:300px;height:300px; padding: 20px">
<calcite-label>Switch label<calcite-switch></calcite-switch></calcite-label>
</div>
<script>
(async () => {
await customElements.whenDefined("calcite-switch");
await document.querySelector("calcite-switch").setFocus();
})();
</script>
`;

FocusLabel_TestOnly.parameters = {
chromatic: { delay: 1000 },
};