From 04557da569e6c5d6cc1c463960a5f78d67213d86 Mon Sep 17 00:00:00 2001 From: ajaxzheng <894103554@qq.com> Date: Tue, 15 Oct 2024 14:30:10 +0800 Subject: [PATCH 1/2] fix(radio): [radio] fix using aria-hidden="true" on focusable elements --- packages/vue/src/radio/src/pc.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/vue/src/radio/src/pc.vue b/packages/vue/src/radio/src/pc.vue index 85a72a69ad..a2521db2cb 100644 --- a/packages/vue/src/radio/src/pc.vue +++ b/packages/vue/src/radio/src/pc.vue @@ -41,7 +41,6 @@ class="tiny-radio__original" :value="label" type="radio" - aria-hidden="true" v-model="state.model" @focus="state.focus = true" @blur="state.focus = false" From f66850afb7f19b00e87f2cf8993014d5ada89465 Mon Sep 17 00:00:00 2001 From: ajaxzheng <894103554@qq.com> Date: Tue, 15 Oct 2024 15:18:44 +0800 Subject: [PATCH 2/2] fix: fix e2e error --- .../sites/demos/pc/app/radio/default-slot.spec.ts | 4 ++-- .../sites/demos/pc/app/radio/group-options.spec.ts | 11 ++++++----- .../sites/demos/pc/app/radio/radio-events.spec.ts | 5 +++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/examples/sites/demos/pc/app/radio/default-slot.spec.ts b/examples/sites/demos/pc/app/radio/default-slot.spec.ts index d77393c918..7bdd783092 100644 --- a/examples/sites/demos/pc/app/radio/default-slot.spec.ts +++ b/examples/sites/demos/pc/app/radio/default-slot.spec.ts @@ -5,8 +5,8 @@ test('默认插槽', async ({ page }) => { await page.goto('radio#default-slot') const demo = page.locator('#default-slot') - const radio1 = demo.getByRole('radio', { name: '内容一:选项描述' }) - const radio2 = demo.getByRole('radio', { name: '内容二:选项描述' }) + const radio1 = demo.locator('label').filter({ hasText: '内容一:选项描述' }) + const radio2 = demo.locator('label').filter({ hasText: '内容二:选项描述' }) await expect(radio1).toBeVisible() await expect(radio2).toBeVisible() }) diff --git a/examples/sites/demos/pc/app/radio/group-options.spec.ts b/examples/sites/demos/pc/app/radio/group-options.spec.ts index 0d70b28d12..c1409c15af 100644 --- a/examples/sites/demos/pc/app/radio/group-options.spec.ts +++ b/examples/sites/demos/pc/app/radio/group-options.spec.ts @@ -3,13 +3,14 @@ import { test, expect } from '@playwright/test' test('配置式单选组', async ({ page }) => { page.on('pageerror', (exception) => expect(exception).toBeNull()) await page.goto('radio#group-options') - const radio1Label = page.locator('.tiny-radio__label').nth(0) - const radio2Label = page.locator('.tiny-radio__label').nth(1) - const radio1 = page.locator('.tiny-radio').nth(0) - const radio2 = page.locator('.tiny-radio').nth(1) + const demo = page.locator('#group-options') + const radio1Label = demo.locator('.tiny-radio__label').nth(0) + const radio2Label = demo.locator('.tiny-radio__label').nth(1) + const radio1 = demo.locator('.tiny-radio').nth(0) + const radio2 = demo.locator('.tiny-radio').nth(1) await expect(radio1).toHaveClass('tiny-radio is-checked') await expect(radio1Label).toHaveText('很好') await expect(radio2Label).toHaveText('一般') - await page.getByRole('radio', { name: '一般' }).click() + await demo.locator('label').filter({ hasText: '一般' }).click() await expect(radio2).toHaveClass('tiny-radio is-focus is-checked') }) diff --git a/examples/sites/demos/pc/app/radio/radio-events.spec.ts b/examples/sites/demos/pc/app/radio/radio-events.spec.ts index 4df6ffb5d2..ab2bd876f1 100644 --- a/examples/sites/demos/pc/app/radio/radio-events.spec.ts +++ b/examples/sites/demos/pc/app/radio/radio-events.spec.ts @@ -5,11 +5,12 @@ test('单选框事件', async ({ page }) => { await page.goto('radio#radio-events') const demo = page.locator('#radio-events') - await demo.getByRole('radio', { name: '选项二' }).click() + + await demo.locator('label').filter({ hasText: '选项二' }).click() const radio1 = page.locator('div').filter({ hasText: 'change 事件,选中的 Radio label 值为:2' }).nth(1) await expect(radio1).toBeVisible() - await demo.getByRole('radio', { name: '月度' }).first().click() + await demo.locator('label').filter({ hasText: '月度' }).first().click() const radio2 = page.locator('div').filter({ hasText: 'change 事件,选中的 Radio label 值为:2' }).nth(1) await expect(radio2).toBeVisible() })