Skip to content

Commit 5253c6a

Browse files
committed
fix(switch): prevent selecting text on double click
1 parent 6f9c6de commit 5253c6a

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

packages/anu-vue/src/components/switch/ASwitch.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export const ASwitch = defineComponent({
6565
return () => (
6666
<label
6767
class={[
68+
'a-switch',
6869
props.label || slots.default
6970
? 'flex'
7071
: 'inline-flex', 'a-switch cursor-pointer uno-layer-base-rounded-full justify-between items-center',
@@ -82,7 +83,9 @@ export const ASwitch = defineComponent({
8283
/>
8384

8485
{/* 👉 Label */}
85-
{slots.default ? slots.default() : props.label}
86+
<div class="a-switch-label">
87+
{slots.default ? slots.default() : props.label}
88+
</div>
8689

8790
{/* 👉 Switch */}
8891
{/* min width should be double the dot size */}

packages/anu-vue/src/presets/theme-default/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ const themeShortcuts: Exclude<Preset['shortcuts'], undefined> = [
136136
'a-select-option': 'em:spacing:px-4 em:spacing:py-1',
137137

138138
// 👉 Switch
139+
'a-switch': 'select-none',
140+
'a-switch-label': 'select-text',
139141
'a-switch-toggle': 'transition-colors transition-duration-100 ease-in-out',
140142
'a-switch-dot': 'h-[1.18em] w-[1.18em] bg-white transition transition-duration-200 ease-[cubic-bezier(0.16,1,0.3,1)]',
141143
'a-switch-icon': 'em:text-xs',

0 commit comments

Comments
 (0)