Skip to content
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
10 changes: 5 additions & 5 deletions examples/sites/demos/pc/app/dialog-box/basic-usage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ test('dialogBox 基础用法', async ({ page }) => {
await page.goto('dialog-box#basic-usage')
const demo = page.locator('#basic-usage')

await page.getByRole('button', { name: /Dialog/ }).click()
await demo.getByRole('button', { name: /Dialog/ }).click()
await demo.getByRole('button', { name: '确 定' }).click()

await page.getByRole('button', { name: /Dialog/ }).click()
await demo.getByRole('button', { name: /Dialog/ }).click()
await demo.getByRole('button', { name: '取 消' }).click()

// 点击 x 图标
await page.getByRole('button', { name: /Dialog/ }).click()
await demo.getByRole('button', { name: /Dialog/ }).click()
await demo.getByLabel('Close').click()

// 点击遮罩时,关闭 dialogBox
await page.getByRole('button', { name: /Dialog/ }).click()
await demo.getByRole('button', { name: /Dialog/ }).click()
await demo.locator('.tiny-dialog-box__wrapper').click()

// 按 ESC 键,关闭 dialogBox
await page.getByRole('button', { name: /Dialog/ }).click()
await demo.getByRole('button', { name: /Dialog/ }).click()
await page.locator('body').press('Escape')
expect(demo.locator('.tiny-dialog-box.is-center > .tiny-dialog-box__header')).toBeHidden()
})
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ test('弹窗表单', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('dialog-box#form-in-dialog')
const demo = page.locator('#form-in-dialog')
const dialogBox = page.locator('.tiny-dialog-box')
const dialogBox = demo.locator('.tiny-dialog-box')
await page.getByRole('button', { name: '弹出表单' }).click()
await expect(dialogBox.locator('.tiny-form')).toBeVisible()
await demo.getByRole('textbox').first().click()
Expand All @@ -17,6 +17,5 @@ test('弹窗表单', async ({ page }) => {

// 验证下拉选择校验提示不会异常
await demo.locator('.tiny-select__tags-group').click()
await page.waitForTimeout(200)
await expect(page.locator('.tiny-form__valid.tiny-tooltip')).not.toBeVisible()
})
5 changes: 4 additions & 1 deletion packages/renderless/src/dialog-box/vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
hideScrollbar,
toggleFullScreen
} from './index'
import { nanoid } from '@opentiny/utils'
import { usePopup } from '@opentiny/vue-hooks'
import type {
IDialogBoxApi,
Expand Down Expand Up @@ -83,7 +84,9 @@ const initState = ({
style: computed(() => api.computedStyle()),
animationName: computed(() => api.computedAnimationName()),
current,
dragStyle: null
dragStyle: null,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Clarify the unrelated dragStyle property addition.

The addition of dragStyle: null appears unrelated to the PR objective of adding ARIA attributes. This property is not mentioned in the PR description, AI summary, or type definitions changes. Please confirm whether this is:

  • An intentional fix that should be documented
  • Part of another feature that got mixed in
  • A necessary property that was previously missing
🤖 Prompt for AI Agents
In @packages/renderless/src/dialog-box/vue.ts at line 87, The new dragStyle:
null property in dialog-box/vue.ts is unrelated to the ARIA changes and should
either be removed or justified: if it was accidentally mixed in, delete the line
and revert any corresponding type additions; if it’s intentional, add a short
inline comment explaining its purpose, update the component’s props/type
definitions (e.g., the dialog component’s props/interface) to include dragStyle,
and mention it in the PR description so reviewers know it’s a deliberate change.
Ensure consistency between the implementation, types, and PR text.

titleId: `tiny-dialog-box-title-${nanoid.api.nanoid(8)}`,
contentId: `tiny-dialog-box-content-${nanoid.api.nanoid(8)}`
})

return state
Expand Down
2 changes: 2 additions & 0 deletions packages/renderless/types/dialog-box.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ export interface IDialogBoxState {
rendered?: boolean
mouseUpWrapperFlag: boolean
mouseDownWrapperFlag: boolean
titleId: string
contentId: string
}

export interface IDialogBoxApi {
Expand Down
8 changes: 6 additions & 2 deletions packages/vue/src/dialog-box/src/pc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@
data-tag="tiny-dialog-box"
:data-dialog-box-draggable="draggable"
:key="state.key"
role="dialog"
:aria-modal="true"
:aria-labelledby="state.titleId"
:aria-describedby="state.contentId"
>
<div v-if="showHeader" ref="header" class="tiny-dialog-box__header" @mousedown="handleDrag">
<slot name="title">
<span class="tiny-dialog-box__title">{{ title }}</span>
<span class="tiny-dialog-box__title" role="heading" :id="state.titleId">{{ title }}</span>
</slot>
<div class="tiny-dialog-box__btn-tools">
<button
Expand Down Expand Up @@ -75,7 +79,7 @@
</button>
</div>
</div>
<div class="tiny-dialog-box__body">
<div class="tiny-dialog-box__body" :id="state.contentId">
<slot></slot>
</div>
<div v-if="slots.footer" ref="footer" class="tiny-dialog-box__footer">
Expand Down
Loading