Repository navigation
Commit 276ca30
fix(components): give the Dialog close button a 44 px touch target at phone width (#29204)
domain:ui#2 · zhuangjianguo · session_01QsR2jRFuJz9QBZqPVHYVhJ
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} -->
_Requested by **Steedos** · [project
thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbCP1P1FEnhJ4Bx9RmczEwBK)_
Fixes #29107
Clause-②: no
Metadata-protocol: none
## 维护者速读
- **改了什么**:手机宽度(小于 sm 断点)下,所有弹窗右上角的关闭按钮从 16×16 px 的点击区扩大到 44×44
px,图标本身仍是 16 px;桌面宽度下按钮样式一字未改。
- **为什么改**:移动端 App 用 WebView 承载 Console,手机用户打开的每个弹窗(操作参数弹窗如审批「驳回」、命令面板
⌘K 等)都用这一个共享 Dialog,关闭按钮太小、经常点不中。
- **风险与回滚**:只加了 `max-sm:` 前缀的样式类,桌面不受影响;图标在手机上向内移动 2 px(距角 17 px → 19
px)。回滚即 revert 本 PR。
- **先看**:`ui/scripts/shadcn-local-patches.mjs`(新增的
`phoneCloseTouchTargetPatches`
补丁声明)、`ui/packages/components/src/ui/dialog.tsx`(Close
那一行)、`ui/packages/components/src/__tests__/dialog-close-touch-target-29107.test.tsx`。
- **两分钟验证**:`pnpm --dir ui exec vitest run
packages/components/src/__tests__/dialog-close-touch-target-29107.test.tsx
scripts/__tests__/shadcn-local-patches.test.ts`,预期全绿;或在 375 px 宽的
Console 里按 Ctrl+K,关闭按钮的点击区是 44×44。
- **需要你做的**:无,席位落地。
## What changes
- The close button `DialogContent` draws in its top-right corner gets a
phone-only touch target: below `sm` it is a 44 x 44 px flex box placed 4
px from the corner with the 16 px glyph centred (`max-sm:right-1
max-sm:top-1 max-sm:flex max-sm:size-11 max-sm:items-center
max-sm:justify-center`, the class set #29078 uses for the Sheet close).
From `sm` up the class list is upstream's, token for token, so the
desktop header does not grow.
- `dialog.tsx` is a Shadcn-synced file (`ui/AGENTS.md` commandment 7),
so the change is declared as a local patch,
`phoneCloseTouchTargetPatches('Dialog')` in
`ui/scripts/shadcn-local-patches.mjs`, anchored on the opening of the
Close element's class list as the vendored registry fixture spells it.
The shipped `dialog.tsx` line was written by applying that patch to the
file, so `REGISTRY_FIXTURES.dialog` keeps its byte round trip
(`roundTrip: true`) and the next `pnpm shadcn:update` re-applies it
instead of reverting it. The helper takes the Radix prefix, so the Sheet
close can take the same family.
- Both sites the card names render `DialogContent`'s own close: the
declared-action param dialog (`ActionParamDialog`, e.g. the
`sys_approval_request` Reject decision) and the command palette
(`CommandDialog`).
- `ui/packages/components/shadcn-components.json`: dialog's `localEdits`
note now names the phone close touch-target patch beside the i18n close
patch (claim amendment 6573487904).
- Changeset `.changeset/29107-dialog-close-phone-touch-target.md`:
`@object-ui/components` patch.
## Tests
- New
`ui/packages/components/src/__tests__/dialog-close-touch-target-29107.test.tsx`:
on `DialogContent` and on `CommandDialog`, the Close carries the six
phone classes, every class without the `max-sm:` prefix equals
upstream's list in order, and the glyph keeps `h-4 w-4`.
- `ui/scripts/__tests__/shadcn-local-patches.test.ts`: the dialog
declares the new patch id; applied to the registry bytes it adds the
phone classes and leaves upstream's Close classes unchanged; it refuses
(only that patch, the close-label family still lands) when upstream
moves the Close off `right-4 top-4`. The two close-label counts on
dialog are scoped to their own family.
- Ablation, one-shot, at 20e48bf: with `dialog.tsx` restored to main's
bytes (tree only, restored from HEAD afterwards, `git status` clean), 4
cases go red: both new component cases, "dialog.tsx carries its declared
patches" and "dialog: byte round-trip holds".
## Acceptance notes
- The glyph moves 2 px on phones: it sat 17 px from the dialog's
top-right edge (16 px placement plus the 1 px border) and now sits 19 px
(4 px placement + 1 px border + 14 px centring inside 44 px). That is
the cost of matching #29078's class set; `max-sm:right-0.5
max-sm:top-0.5` would keep it at 17 px.
- The 2 px glyph shift above is accepted by the seat: it keeps the
Dialog and Sheet class sets identical.
- `sheet.tsx`'s close is #29078's; `REGISTRY_FIXTURES.sheet` is
`roundTrip: true` as well, so a bare class edit there reds "sheet: byte
round-trip holds" unless it is declared the same way.
## Verification
- Real browser, showcase backend plus the Console Vite dev server,
Playwright at 375 x 812 and 1280 x 800, measuring the dialog element's
own Close (screenshots and the script stay in the project files, not
here):
- Before (main's `dialog.tsx`): param dialog and command palette Close
are 16 x 16 px at 375 px and at 1280 px.
- After: 44 x 44 px at 375 px on both sites, glyph 16 x 16; at 1280 px
both are still 16 x 16 px at the same position.
- Local gates at 20e48bf: the 36 families `dispatch-gates --commands`
derives for this diff all exit 0 (`--ran` reconciliation: 36 derived, 36
run, 0 NOT-MEASURED), including `node scripts/check-sdui-manifest.mjs`
and `pnpm --dir ui exec vitest run scripts/` (169 files, 4903 tests
passed). `@object-ui/components` type-check (including
`tsconfig.test.json`) exit 0; eslint on the four touched source files
exit 0; `pnpm check:new-line-citations` 0 new.
- After merging main (d0c0add, no main commit touches these files): the
three touched test files re-run green (66 tests).
- At cc550d3 (the `localEdits` note): the same 36 derived families; the
files that read `shadcn-components.json` plus the patch and dialog tests
re-run green (5 files, 92 tests), `check:published-files`,
`check:nul-bytes` and `check-empty-changeset` exit 0.
- At 1855aa3: `snapshot-critical.test.tsx` ("Dialog snapshots > renders
open dialog structure", red in Test UI 10/16 on cc550d3) regenerated
with `vitest --update`; the `.snap` diff is the Close line only, gaining
the six `max-sm:` classes. A sweep of every `*.snap`, `*.test.*` and
`*.spec.*` file for the Close class list (`right-4 top-4 rounded-sm`,
`rounded-sm opacity-70`, `data-[state=open]:bg-accent
data-[state=open]:text-muted-foreground`) finds no other pin. The
snapshot file and the dialog test re-run green (2 files, 22 tests); the
whole components package did not finish locally within 560 s, so CI Test
UI carries it.
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes.
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QsR2jQryAdPcJnhAWQzVjB)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 5cdaf9a commit 276ca30
7 files changed
Lines changed: 225 additions & 6 deletions
File tree
- .changeset
- ui
- packages/components
- src
- __tests__
- __snapshots__
- ui
- scripts
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | | - | |
| 134 | + | |
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
492 | 492 | | |
493 | 493 | | |
494 | 494 | | |
495 | | - | |
| 495 | + | |
496 | 496 | | |
497 | 497 | | |
498 | 498 | | |
| |||
| 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 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
361 | 422 | | |
362 | 423 | | |
363 | 424 | | |
| |||
444 | 505 | | |
445 | 506 | | |
446 | 507 | | |
447 | | - | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
448 | 513 | | |
449 | 514 | | |
450 | 515 | | |
| |||
459 | 524 | | |
460 | 525 | | |
461 | 526 | | |
462 | | - | |
| 527 | + | |
463 | 528 | | |
464 | 529 | | |
465 | 530 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
648 | 648 | | |
649 | 649 | | |
650 | 650 | | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
651 | 701 | | |
652 | 702 | | |
653 | 703 | | |
654 | 704 | | |
655 | 705 | | |
656 | 706 | | |
657 | 707 | | |
658 | | - | |
| 708 | + | |
659 | 709 | | |
660 | 710 | | |
661 | 711 | | |
| |||
0 commit comments