Skip to content

Commit a527d70

Browse files
authored
fix: modify the issue of radio and checkbox components being unclickable (#37)
* fix: optimize the radio component * fix: revised version * fix(radio): remove invalid events * fix: modify the test version * fix: modify the test version * fix: optimize label tags and add corresponding IDs * fix: cannot click after component reference, modify checkbox style * fix: modify version * fix: modify the selection of invalid issues for radio and checkbox
1 parent e97c839 commit a527d70

9 files changed

Lines changed: 46 additions & 19 deletions

File tree

packages/demos/app/radio/event.vue

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,36 @@
44
<tiny-radio v-model="value" label="1" @change="changeAction">男</tiny-radio>
55
<tiny-radio v-model="value" label="2" @change="changeAction">女</tiny-radio>
66
<p>{{ text }}</p>
7+
<br/> <br/>
8+
<tiny-checkbox-group v-model="checked" class="demo-checkbox-group">
9+
<tiny-checkbox label="复选框1">复选框1</tiny-checkbox>
10+
<tiny-checkbox label="复选框2">复选框2</tiny-checkbox>
11+
</tiny-checkbox-group>
12+
<p>当前选中的值为:{{ checked }}</p>
713
</div>
814
</template>
915

1016
<script setup>
1117
import { ref } from 'vue'
12-
import { TinyRadio } from '@opentiny/vue-mobile'
18+
import { TinyRadio, TinyCheckbox, TinyCheckboxGroup } from '@opentiny/vue-mobile'
1319
1420
const value = ref('1')
1521
const text = ref('')
22+
const checked = ref(['复选框1'])
23+
1624
1725
function changeAction(value) { // NISVUE3 FIXME: value重复定义,请手工修改
1826
text.value = value === '1' ? '' : ''
1927
}
2028
</script>
2129

2230
<style>
31+
.demo-checkbox-group {
32+
display: flex;
33+
justify-content: flex-start;
34+
flex-wrap: nowrap;
35+
width: 200px;
36+
}
2337
.demo {
2438
height: 100%;
2539
overflow-y: auto;

packages/mobile/components/radio/src/mobile.vue

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@
1212
<template>
1313
<label
1414
class="tiny-mobile-radio"
15-
:class="[{ 'is-disabled': state.isDisabled }, { 'is-focus': state.focus }, { 'is-checked': state.model === label }]"
15+
:class="[{ 'is-disabled': state.isDisabled },
16+
{ 'is-focus': state.focus },
17+
{ 'is-checked': state.model === label }]"
1618
role="radio"
1719
:aria-checked="state.model === label"
1820
:aria-disabled="state.isDisabled"
1921
:tabindex="state.tabIndex"
20-
@keydown.space.stop.prevent="state.model = state.isDisabled ? state.model : label"
22+
@keydown.space.stop.prevent="
23+
state.model = state.isDisabled ? state.model : label
24+
"
2125
>
2226
<div class="tiny-mobile-radio__input">
2327
<div class="tiny-mobile-radio__outer">
@@ -29,7 +33,6 @@
2933
class="tiny-mobile-radio__original"
3034
:value="label"
3135
type="radio"
32-
aria-hidden="true"
3336
v-model="state.model"
3437
@focus="state.focus = true"
3538
@blur="state.focus = false"
@@ -39,9 +42,9 @@
3942
tabindex="-1"
4043
/>
4144
</div>
42-
<span class="tiny-mobile-radio__label" @keydown.stop>
43-
<slot>{{ text || label }}</slot>
44-
</span>
45+
<span class="tiny-mobile-radio__label">
46+
<slot>{{ text || label }}</slot>
47+
</span>
4548
</label>
4649
</template>
4750

packages/mobile/components/radio/src/renderless/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,4 @@ export const toggleEvent = ({ props, vm, type }: Pick<IRadioRenderlessParams, 'p
103103
})
104104
}
105105
}
106+

packages/mobile/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@opentiny/vue-mobile",
33
"type": "module",
4-
"version": "1.0.0-alpha.11",
4+
"version": "1.0.0-alpha.11.5",
55
"description": "An enterprise-class UI component library, support both Vue.js 2 and Vue.js 3, as well as PC and mobile.",
66
"author": "OpenTiny Team",
77
"license": "MIT",

packages/theme-mobile/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@opentiny/vue-theme-mobile",
3-
"version": "1.0.0-alpha.11",
3+
"version": "1.0.0-alpha.11.5",
44
"description": "An enterprise-class UI component library, support both Vue.js 2 and Vue.js 3, as well as PC and mobile.",
55
"homepage": "https://opentiny.design/tiny-vue",
66
"main": "index.css",

packages/theme-mobile/src/checkbox/index.less

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919

2020
.@{checkbox-prefix-cls} {
2121
.inject-Checkbox-vars();
22-
22+
23+
width: 100%;
2324
position: relative;
2425
display: inline-block;
2526
white-space: nowrap;
@@ -85,10 +86,11 @@
8586
opacity: 0;
8687
outline: 0;
8788
position: absolute;
88-
margin: 0;
89-
width: 0;
90-
height: 0;
91-
z-index: -1;
89+
inset: 0;
90+
width: var(--tvm-Checkbox-heatmap-width);
91+
height: var(--tvm-Checkbox-heatmap-height);
92+
opacity: 0;
93+
z-index: 2;
9294
}
9395

9496
&__label {

packages/theme-mobile/src/checkbox/vars.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,8 @@
3535
--tvm-Checkbox-checked-disabled-bg-color: var(--tvm-color-bg-disabled-control-checked, #dbdbdb);
3636
// 复选框禁用图标边框色
3737
--tvm-Checkbox-disabled-border-color: var(--tvm-color-bg-disabled-control-unactive, #dbdbdb);
38+
// 复选框热区宽度
39+
--tvm-Checkbox-heatmap-width: var(--tvm-base-size-width-large);
40+
// 复选框热区高度
41+
--tvm-Checkbox-heatmap-height: var(--tvm-base-size-height-mini);
3842
}

packages/theme-mobile/src/radio/index.less

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,10 @@
137137
opacity: 0;
138138
outline: 0;
139139
position: absolute;
140-
z-index: -1;
141-
top: 0;
142-
left: 0;
143-
right: 0;
144-
bottom: 0;
140+
z-index: 1;
141+
inset: 0;
142+
width: var(--tvm-Radio-heatmap-width);
143+
height: var(--tvm-Radio-heatmap-height);
145144
margin: 0;
146145
}
147146

packages/theme-mobile/src/radio/vars.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,8 @@
2121
--tvm-Radio-label-text-color: var(--tvm-color-text, #191919);
2222
// 文字左边距
2323
--tvm-Radio-label-padding-left: var(--tvm-space-lg, 12px);
24+
// 热区宽度
25+
--tvm-Radio-heatmap-width: var(--tvm-base-size-width-large);
26+
// 热区高度
27+
--tvm-Radio-heatmap-height: var(--tvm-base-size-height-mini);
2428
}

0 commit comments

Comments
 (0)