fix: complete TagGroup semantics event ownership and removal focus

This commit is contained in:
maoyingjie
2026-10-25 14:34:07 +08:00
parent af6bfda3ee
commit 20d34d7169
12 changed files with 528 additions and 53 deletions
+2 -2
View File
@@ -89,11 +89,11 @@ HeroUI 遵循 [BEM](https://getbem.com/) 方法论,确保组件变体与状态
ErrorMessage 组件使用以下 CSS 类([查看源码样式](https://github.com/heroui-inc/heroui/blob/v3/packages/styles/components/error-message.css)):
#### 基础类 [!toc]
#### 基础类
- `.hv-error-message` - 基础错误消息样式,danger 色与文本换行
#### 插槽类 [!toc]
#### 插槽类
- `[slot="errorMessage"]` - 与固定基线一致的 DOM 标记,可用作 CSS 选择器
- `[data-slot="error-message"]` - 组件标记
+17 -17
View File
@@ -100,7 +100,7 @@ import {
<ComponentPreview name="tag-group-render-function" />
上游用 React `render` 函数替换根 DOM 元素;Vue 中对应 `as`(自定义根元素标签)与 `as-child`(使用自定义组件作为唯一根)。本库示例用 `as="section"` 演示同一能力。
上游用 React `render` 函数替换根 DOM 元素;Vue 中对应 `as`(自定义根元素标签)与 `as-child`(使用自定义组件作为唯一根)。本库示例用 `as="div"` 演示同一能力。
## 自定义样式
@@ -140,30 +140,30 @@ HeroUI 遵循 [BEM](https://getbem.com/) 方法论,确保组件变体与状态
TagGroup 组件使用以下 CSS 类([查看源码样式](https://github.com/heroui-inc/heroui/blob/v3/packages/styles/components/tag-group.css) 与 [tag.css](https://github.com/heroui-inc/heroui/blob/v3/packages/styles/components/tag.css)):
#### 基础类 [!toc]
#### 基础类
- `.hv-tag-group` - TagGroup 根容器
- `.hv-tag-group__list` - 标签列表容器
- `.hv-tag` - 标签基础样式
- `.hv-tag__remove-button` - 移除按钮触发器
#### 插槽类 [!toc]
#### 插槽类
- `.hv-tag-group [data-slot="description"]` - Description 插槽样式
- `.hv-tag-group [data-slot="error-message"]` - ErrorMessage 插槽样式
#### 尺寸类 [!toc]
#### 尺寸类
- `.hv-tag--sm` - 小尺寸标签
- `.hv-tag--md` - 中尺寸标签(默认)
- `.hv-tag--lg` - 大尺寸标签
#### 变体类 [!toc]
#### 变体类
- `.hv-tag--default` - 默认变体
- `.hv-tag--surface` - 带 Surface 背景的变体
#### 状态类 [!toc]
#### 状态类
- `.hv-tag[data-selected="true"]` - 选中状态
- `.hv-tag[data-disabled="true"]` - 禁用状态
@@ -226,15 +226,15 @@ TagGroup 组件使用以下 CSS 类([查看源码样式](https://github.com/he
### Tag
| Prop | 类型 | 默认值 | 描述 |
| ------------- | --------------------------- | ------- | -------------------------------------------------- |
| `id` | `string \| number` | - | 标签唯一标识(必填,集合 key) |
| `text-value` | `string` | - | 标签内容的字符串表示,用于无障碍名称与移除按钮名称 |
| `is-disabled` | `boolean` | `false` | 是否禁用该标签 |
| `as` | `string` | `'div'` | 自定义行元素标签 |
| `as-child` | `boolean` | `false` | 使用唯一子元素作为行节点并合并属性 |
| 默认插槽 | `{ ...TagRenderState }` | - | 标签内容;作用域提供渲染状态 |
| `class` | `string \| Array \| Object` | - | 附加 CSS 类(Vue class 绑定) |
| Prop | 类型 | 默认值 | 描述 |
| ------------- | --------------------------- | ------- | ------------------------------------------------------------ |
| `id` | `string \| number` | - | 标签唯一标识(必填,集合 key) |
| `text-value` | `string` | - | 标签内容的字符串表示,用于无障碍名称与移除按钮名称 |
| `is-disabled` | `boolean` | `false` | 是否禁用该标签 |
| `as` | `string` | `'div'` | 自定义行元素标签 |
| `as-child` | `boolean` | `false` | 使用唯一子元素作为行节点并合并属性;组件需透传属性与默认插槽 |
| 默认插槽 | `{ ...TagRenderState }` | - | 标签内容;作用域提供渲染状态 |
| `class` | `string \| Array \| Object` | - | 附加 CSS 类(Vue class 绑定) |
**提示:** `size`、`variant` 由父级 `TagGroup` 继承,不能在单个 `Tag` 上直接设置。
@@ -273,12 +273,12 @@ TagGroup 组件使用以下 CSS 类([查看源码样式](https://github.com/he
## 无障碍
- 列表节点为 `role="grid"`,每个标签为 `role="row"`,行的可访问名称来自其文本内容。
- 列表节点为 `role="grid"`,每个标签为 `role="row"`,行包含 `gridcell`,可访问名称来自其文本内容。
- 方向键在标签之间移动焦点(RTL 下左右互换),`Home` / `End` 跳到第一个 / 最后一个标签;禁用标签会被跳过。
- `Enter` 与 `Space` 切换选中(`Space` 在 `keyup` 时激活,调用方可通过 `preventDefault` 取消)。
- `Backspace` / `Delete` 在允许移除时请求移除当前聚焦标签。
- 移除确认后焦点移到原位置的下一个标签,删除最后一项时回到列表本身;父级拒绝删除时标签与焦点都保留。
- 列表节点声明 `aria-atomic="false"` 与 `aria-relevant="additions text"`,集合内容的增删会被读屏软件播报。
- 列表保留 `aria-atomic="false"` 与 `aria-relevant="additions text"` 标记;独立的 polite 状态区域在确认移除后更新公告,父级拒绝移除时不公告。实际读屏效果尚未验证。
## 相关组件