Skip to content

[components] 内建 select 的空选项/依赖门态分支把 host id 落在一个 div 上 —— label 的 for 指向不可 label 元素,仍是不关联的 #3991

Description

@yinlianghui

实施 #3976(内建 select 分支的 host id 落到真实 trigger)时顺手测到的相邻状态,#3976 的修法不相交,单独记录。

实测(probe,未提交;#3976 的修改对这一条无影响)

一个 { name: 'empty', label: 'Empty', type: 'select', options: [] }:

label for = _r_7_-form-item   ->  owner tag = DIV

DOM:

label class="…" for="_r_7_-form-item">Empty</label>
div class="text-sm text-muted-foreground" id="_r_7_-form-item"
    aria-describedby="_r_7_-form-item-description" aria-invalid="false">No options available</div>

即:选项为空(或 #2284 的依赖门态,emptyHint 分支)时,内建 select 渲染的是
BuiltinSelectEmptyState 那个 div,FormControl(Radix Slot)下发的 id 就落在这个 div 上,
FormLabelfor 指向它。for 只能指向可 label 元素(button / input / meter /
output / progress / select / textarea),指向 div 是惰性 HTML。

与既有工作的关系

影响面(诚实说:很小,所以按 observation 记)

  • 用户侧:空状态里没有任何可聚焦控件,所以「点标签没反应」与「控件无可访问名」都无处发生 —— 名字要命名的东西不存在。
  • 作者/测试侧有真实摩擦:对这样的字段 getByLabelText('Empty') 会抛
    "found a label … however no form control was found associated to that label",
    读起来像渲染器坏了,而实际是空状态。
  • 同形的还有 @object-ui/fieldsOptionsEmptyState(注册 widget 路径的空状态),如果这一条要修,两条路径应一起看。

严重度交 PM 分诊;这里只按 #4949 的纪律把事实与证据落到纸面。

参考

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions