[Bug]: slotted labels not associated with input during hydration in fluent-field
维护者通常 2 天内回复
@chrisdholt 已经在做这个了。
开始于 2026年9月15日。
评估
这个 Issue 还没有评估数据。
描述
🐛 Bug Report
When a <fluent-field> is server-rendered and hydrated, its initial slotted label and input are not associated. The label remains without for or id, and the input remains without aria-labelledby.
💻 Repro or Code Sample
Server-render and hydrate this markup:
<fluent-field>
<label slot="label">Label</label>
<input id="input" slot="input" />
</fluent-field>
After hydration, inspect the slotted elements or assert:
await expect(label).toHaveAttribute("for", "input");
await expect(label).toHaveAttribute("id", "input--label");
await expect(input).toHaveAttribute("aria-labelledby", "input--label");
The failure reproduces in the chromium-ssr Playwright project.
🤔 Expected Behavior
Initial connection should associate the slotted label and input:
<label slot="label" for="input" id="input--label">Label</label>
<input id="input" slot="input" aria-labelledby="input--label" />
😯 Current Behavior
The association attributes remain unset after hydration:
Error: expect(locator).toHaveAttribute(expected) failed
Locator: locator('fluent-field').locator('label')
Expected: "input"
Received: ""
No component error is thrown, but clicking the label may not focus the input and assistive technology may not receive the label as the input's accessible name.
💁 Possible Solution
setLabelProperties() checks $fastController.isConnected. During hydration, the initial labelSlotChanged and inputChanged callbacks can run before the controller reports that it is connected. The method skips its work, and Field does not call it again after connection.
Remove the connection guard and add an SSR regression test for the generated association attributes. I am willing to contribute the fix and test.
As an alternative, authors can provide definite id and for attributes on their slotted label, and a matching aria-labelledby attribute on the slotted input. We should add tests for both scenarios.
🔦 Context
This affects server-rendered forms using the Fluent Field web component. Client-side rendering works, but hydration leaves the initial label and input without their expected accessibility association.
🌍 Your Environment
- OS & Device: macOS on Mac
- Browser: Chromium through Playwright's
chromium-ssrproject - Version:
@fluentui/web-components3.1.2 - FAST Element:
@microsoft/fast-element3.0.2 - Node.js: 24.18.0
- 主要语言
- TypeScript
- 星标
- 20.4k
- 派生
- 3k
- 平均合并
- 3 天 21 小时
- 30 天内合并 PR
- 99
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/fluentui 的其他 Issue
-
[Bug]: Accordion crashes for scalar `defaultOpenItems={0}` (headless and styled v9)可能已有人在做 @arniebradfo 于 4 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 2 天内回复
-
[Bug]: Button shims in react-migration-v8-v9 always render the ms-Button--primary class可能已有人在做 @jakesalvesen 于 15 天前认领。 未关闭Component: Button Fluent UI react-components (v9) Type: Bug :bug:
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 2 天内回复
-
[Bug]: AreaChart renders SVG rect with negative width and height on initial render可能已有人在做 @AtishayMsft 于 12 天前认领。 未关闭Package: charting Type: Bug :bug:
难度 2/5 1-3 小时 新手友好度 76/100
microsoft/fluentui#36976 · 已指派 1 人 ·
维护者通常 2 天内回复
-
[Bug]: Vertical Slider still logs the deprecated 'slider-vertical' warning in Chromium 132+可能已有人在做 @jakesalvesen 于 18 天前认领。 未关闭Component: Slider Fluent UI react-components (v9) Type: Bug :bug:
难度 2/5 1-3 小时 新手友好度 74/100
microsoft/fluentui#36945 · 1 条评论 ·
维护者通常 2 天内回复
-
[Bug]: fluent-checkbox submits "on" when the checked attribute is before value可能已有人在做 @FOWEPJF255 于 12 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 2 天内回复
查看 microsoft/fluentui 的全部 Issue
相似的 Issue
-
难度 1/5 1-3 小时 新手友好度 86/100
ranxianglei/billion-context#5893 ·
维护者通常 1 天内回复
-
stringify escapes leading digits in pseudo-class arguments (:nth-child(1) becomes :nth-child(\31 ))未关闭
难度 2/5 1-3 小时 新手友好度 83/100
维护者通常 1 天内回复
-
enhancement security severity:low
难度 2/5 1-3 小时 新手友好度 83/100
Battle-Cattle/BCUK-Bot-4#959 ·
维护者通常 1 天内回复
-
[Bug]: Claude account rows no longer show the email (since #8055), so "Account 1, 2, 3" cannot be told apart可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭account-pool bug gui
难度 2/5 1-3 小时 新手友好度 76/100
lidge-jun/opencodex#8286 · 2 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 72/100
维护者通常 1 天内回复