Repository navigation
Commit ef777b8
fix(app-shell): name the copy buttons in an action's result dialog and announce the copied state (#28265)
<!-- claude-projects-attribution: {"github_login":"os-tesla"} -->
_Requested by **Tesla** · [project
thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6JaoCFC5prTTPschL4i6Cz14L9)_
Fixes #28186
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:动作结果弹窗(邀请链接、新 API 密钥、2FA 密钥等只显示一次的值)里每个仅图标的「复制」按钮现在都有可读的名称,例如「复制
Email」;没有字段标签时叫「复制值」,备用码列表按序号叫「复制 备用码 第 2 项」。复制成功后,读屏会念出「已复制到剪贴板」。
- 为什么改:读屏或语音控制用户以前只听到「按钮」,分不清它是复制哪个值,也没法按名字点它;值只显示一次,漏复制就得把动作重做一遍。
- 风险与回滚:只改渲染层,弹窗的布局与复制行为不变(新的播报区是视觉隐藏的);十个语言包各加 5 个键。回滚即 revert 本 PR。
-
先看:`ui/packages/app-shell/src/views/ActionResultDialog.tsx`(`CopyButton`
与 `ResultField` 里的
`copyName`);`ui/packages/app-shell/src/views/__tests__/ActionResultDialog.test.tsx`
新增的 describe;`ui/packages/i18n/src/locales/en.ts` 的
`actions.resultDialog`。
- 两分钟验证:`pnpm --dir ui exec vitest run
packages/app-shell/src/views/__tests__/ActionResultDialog.test.tsx`,预期 1
个文件、12 个测试全绿。
- 需要你做的:无,席位落地。
## What changes
**Names** (`ui/packages/app-shell/src/views/ActionResultDialog.tsx`).
`ResultField` already resolves the field's `I18nLabel`; it now builds
the accessible name of that field's copy buttons from it and hands it to
the format block (`QrcodeBlock`, `SecretBlock`, `TextBlock`,
`JsonBlock`, `CodeListBlock`):
- a labelled field: `actions.resultDialog.copyField` ("Copy LABEL");
- an unlabelled field, including the whole-payload JSON fallback:
`actions.resultDialog.copyValue` ("Copy value");
- each code of a code list, by 1-based position: `copyFieldItem` ("Copy
LABEL, item N") or `copyItem` ("Copy item N").
`CopyButton` takes either a visible `label` (that text is its name, as
"Copy all" already was) or a `name` that becomes its `aria-label`; the
prop type makes one of the two required, so a new icon-only use cannot
compile without a name. The `Copy` / `Check` icons are marked
`aria-hidden`.
**Copied state.** Each `CopyButton` renders a visually hidden
`role="status"` region (implicitly polite) beside the button. It is
mounted empty and filled with `actions.resultDialog.copied` ("Copied to
clipboard") while the copied state lasts, so a screen reader announces
the change. It is positioned out of flow by `sr-only`, so the flex rows
keep their layout.
**Translations.** The five keys are added under `actions.resultDialog`
in all ten packs (`en`, `zh`, `ja`, `ko`, `de`, `fr`, `es`, `pt`, `ru`,
`ar`), next to the existing `copyAll`.
**#27521's focus pins.** The change does not touch
`useActionDialogReturnFocus` or the dialog's focus props;
`actionDialogFocus-27521.test.tsx` is run below as a control.
## Tests
`ui/packages/app-shell/src/views/__tests__/ActionResultDialog.test.tsx`
gains a describe, "every copy button has an accessible name", with
role-and-name queries. The file's `useObjectTranslation` stub now echoes
interpolation params after the key, so a name shows which label reached
it (existing assertions use no params and are unchanged).
- each of a text, secret, qrcode and json field's copy button is found
by `getByRole('button', { name:
'actions.resultDialog.copyField(label=LABEL)' })`;
- the whole-payload fallback's button is named `copyValue`;
- a labelled code list's per-code buttons are named `copyFieldItem` with
index 1 and 2, and "Copy all" keeps its visible name; an unlabelled
list's are named `copyItem`;
- no button in the dialog is left without a name (all buttons equal the
buttons with a non-blank name);
- the `status` region exists and is empty before the click, `writeText`
receives the value, and the same region node then reads
`actions.resultDialog.copied`.
## Acceptance notes
- "Copy all" keeps its visible text as its accessible name. Two
code-list fields in one dialog would show two "Copy all" buttons with
the same name; no shipped `resultDialog` declares two code lists, so
this is noted, not changed.
- The live region announces only a successful copy. A refused clipboard
write still does nothing visible or audible, as before; the value stays
on screen for a manual copy.
## Verification
Tree: objectstack-ai/objectstack, branch head named in the os-dev report
on the card.
<details><summary>Result dialog tests</summary>
```
pnpm --dir ui exec vitest run packages/app-shell/src/views/__tests__/ActionResultDialog.test.tsx
Test Files 1 passed (1)
Tests 12 passed (12)
os-verify-lock: VERDICT command-exit 0
```
</details>
<details><summary>Ablation: the fix removed, the new pins go
red</summary>
`aria-label` on `CopyButton` and the `status` span deleted (0 hits for
each confirmed on disk), same command:
```
× names each field's copy button after the field label
× names an unlabelled value's copy button generically
× names each code of a code list by its position, and keeps the visible name of Copy all
× names the codes of an unlabelled code list by position alone
× leaves no button in the dialog without a name
× announces the copied state in a live region that is mounted before it fills
Tests 6 failed | 6 passed (12)
os-verify-lock: VERDICT command-exit 1
```
Restored with `git checkout HEAD --`; `git diff HEAD` empty afterwards.
The 6 pre-existing tests stayed green in both legs.
</details>
<details><summary>Derived gates (dispatch-gates --commands, head
f68fcad): 34 of 34 exit 0, reconciliation 34 run, 0 NOT-MEASURED, 0
UNRUN</summary>
```
node scripts/check-adr-0087-registration.mjs --base origin/main :: exit 0
node scripts/check-adr-0087-registration.mjs --self-test :: exit 0
node scripts/check-changeset-no-major.mjs --base origin/main :: exit 0
node scripts/check-closing-keyword-parity.mjs :: exit 0
node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0
node scripts/check-comment-mask-corpus.mjs :: exit 0
node scripts/check-empty-changeset.mjs --base origin/main :: exit 0
node scripts/check-empty-changeset.mjs --self-test :: exit 0
node scripts/check-sdui-manifest.mjs :: exit 0
node scripts/check-sdui-manifest.mjs --self-test :: exit 0
node scripts/pm/release-rehearsal-clone.mjs --self-test :: exit 0
node scripts/release-pending-publish.mjs --self-test :: exit 0
pnpm --filter @objectstack/spec run check:duration-unit-keys :: exit 0
pnpm check:changeset-gate-self-tests :: exit 0
pnpm check:closed-ceremony-text :: exit 0
pnpm check:cross-package-test-inputs :: exit 0
pnpm check:dispatcher-error-vocabulary :: exit 0
pnpm check:driver-memory-census :: exit 0
pnpm check:engine-double-contract :: exit 0
pnpm check:gitlink-declared :: exit 0
pnpm check:nul-bytes :: exit 0
pnpm check:pm-changeset-deadline-census :: exit 0
pnpm check:published-files :: exit 0
pnpm check:query-options-erasure :: exit 0
pnpm check:refd-timer-probe :: exit 0
pnpm check:skill-identifier-liveness :: exit 0
pnpm check:test-source-alias :: exit 0
pnpm check:tier-file-adoption :: exit 0
pnpm check:type-check-coverage :: exit 0
pnpm check:type-check-debt :: exit 0
pnpm check:undeclared-dep-imports :: exit 0
pnpm check:watch-hint-literal :: exit 0
pnpm check:where-matcher :: exit 0
pnpm --dir ui exec vitest run scripts/ :: exit 0
```
`check:type-check-debt` first hit a 500 s `timeout` wrapper while the
type-check below held the box (exit 124); re-run alone, exit 0, and the
record carries that code.
</details>
<details><summary>Type-check, sibling tests and line citations</summary>
```
pnpm --filter @object-ui/i18n run type-check && pnpm --filter @object-ui/app-shell run type-check (after a full dts build of @object-ui/app-shell^...)
os-verify-lock: VERDICT command-exit 0
pnpm --dir ui exec vitest run packages/app-shell/src/views/actionDialogFocus-27521.test.tsx packages/app-shell/src/views/ObjectView.inviteOutcome-27797.test.tsx packages/i18n/
Test Files 95 passed (95)
Tests 1445 passed | 13 skipped (1458)
pnpm --dir ui run check:new-line-citations
VERDICT new-cross-file-line-citations: 0 new citation(s), enforcement report-only -> exit 0
```
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01L9qibvSA9x5ZD2RncR2GRx)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent c3842ac commit ef777b8
13 files changed
Lines changed: 249 additions & 23 deletions
File tree
- .changeset
- ui/packages
- app-shell/src/views
- __tests__
- i18n/src/locales
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
165 | | - | |
| 165 | + | |
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
170 | 179 | | |
171 | 180 | | |
172 | 181 | | |
| |||
183 | 192 | | |
184 | 193 | | |
185 | 194 | | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
191 | 202 | | |
192 | 203 | | |
193 | 204 | | |
| |||
212 | 223 | | |
213 | 224 | | |
214 | 225 | | |
215 | | - | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
216 | 238 | | |
217 | 239 | | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
222 | 249 | | |
223 | 250 | | |
224 | 251 | | |
225 | | - | |
| 252 | + | |
226 | 253 | | |
227 | 254 | | |
228 | 255 | | |
| |||
247 | 274 | | |
248 | 275 | | |
249 | 276 | | |
250 | | - | |
| 277 | + | |
251 | 278 | | |
252 | 279 | | |
253 | 280 | | |
254 | 281 | | |
255 | 282 | | |
256 | | - | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
257 | 290 | | |
258 | 291 | | |
259 | 292 | | |
| |||
265 | 298 | | |
266 | 299 | | |
267 | 300 | | |
268 | | - | |
| 301 | + | |
269 | 302 | | |
270 | 303 | | |
271 | 304 | | |
| |||
277 | 310 | | |
278 | 311 | | |
279 | 312 | | |
280 | | - | |
| 313 | + | |
281 | 314 | | |
282 | 315 | | |
283 | 316 | | |
| |||
294 | 327 | | |
295 | 328 | | |
296 | 329 | | |
297 | | - | |
| 330 | + | |
298 | 331 | | |
299 | 332 | | |
300 | 333 | | |
301 | 334 | | |
302 | | - | |
| 335 | + | |
303 | 336 | | |
304 | 337 | | |
305 | 338 | | |
306 | 339 | | |
307 | 340 | | |
308 | | - | |
| 341 | + | |
309 | 342 | | |
310 | 343 | | |
311 | 344 | | |
312 | 345 | | |
313 | | - | |
| 346 | + | |
314 | 347 | | |
315 | 348 | | |
316 | 349 | | |
| |||
324 | 357 | | |
325 | 358 | | |
326 | 359 | | |
327 | | - | |
| 360 | + | |
328 | 361 | | |
329 | 362 | | |
330 | 363 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
21 | 29 | | |
22 | 30 | | |
23 | 31 | | |
| |||
131 | 139 | | |
132 | 140 | | |
133 | 141 | | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
153 | 160 | | |
154 | 161 | | |
155 | 162 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
139 | 146 | | |
140 | 147 | | |
141 | 148 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
156 | 163 | | |
157 | 164 | | |
158 | 165 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
141 | 148 | | |
142 | 149 | | |
143 | 150 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
141 | 148 | | |
142 | 149 | | |
143 | 150 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
139 | 146 | | |
140 | 147 | | |
141 | 148 | | |
| |||
0 commit comments