From e32c0227cd8799ff14081f316d3ea0970ac46267 Mon Sep 17 00:00:00 2001 From: AcWrong02 <147061401+AcWrong02@users.noreply.github.com> Date: Wed, 28 Feb 2024 18:06:13 +0800 Subject: [PATCH] fix(Switch): [Switch] add keydown support and improth the accessibility (#1428) --- packages/theme/src/switch/index.less | 9 ++++++++- packages/vue/src/switch/src/pc.vue | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/theme/src/switch/index.less b/packages/theme/src/switch/index.less index 8026ac2b37..e0805f08f5 100644 --- a/packages/theme/src/switch/index.less +++ b/packages/theme/src/switch/index.less @@ -29,7 +29,14 @@ position: relative; cursor: pointer; outline: none; - transition: all 0.2s ease-in-out; + transition: + border 0.2s ease-in-out, + background-color 0.2s ease-in-out; + + &:focus-visible { + outline: 2px solid var(--ti-switch-on-bg-color); + outline-offset: 1px; + } & &-inner { color: var(--ti-switch-text-color); diff --git a/packages/vue/src/switch/src/pc.vue b/packages/vue/src/switch/src/pc.vue index 5b9b328078..d54aca0fea 100644 --- a/packages/vue/src/switch/src/pc.vue +++ b/packages/vue/src/switch/src/pc.vue @@ -16,6 +16,7 @@ :tabindex="tabindex" @click="toggle" @keydown.space="toggle" + @keydown.enter="toggle" >