Repository navigation
Commit db1a05c
fix(components): page header actions show an in-flight state while their click runs (#34956)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs
Fixes #34933
Clause-②: no
Metadata-protocol: none
## 维护者速读
-
改了什么:记录页头部动作按钮在点击后、结果或对话框到来前,显示「进行中」:按钮标为不可用(`aria-disabled`)但仍可获得焦点、`aria-busy`、图标换成转圈,再点无效;手机底部动作栏同样处理,`⋯`
菜单项用原生禁用。确认对话框关闭后焦点回到按钮(第 1 轮,L1 S1)。
- 为什么改:Convert Lead 这类慢动作(流程要先走网络再开向导)点击后按钮毫无反应,用户会重复点击(hotcrm 实测)。
- 风险与回滚:只改 `containers.tsx` 一个渲染器;点击返回 promise 才进入忙碌态,同步点击(如
Edit)不受影响。回滚即 revert 本 PR。
- 先看:`ui/packages/components/src/renderers/layout/containers.tsx` 的
`runHeaderAction`(忙碌态与 settle);同文件 `dispatchHeaderAction` 现在返回 `execute`
的 promise;测试 `page-header-actions.test.tsx` 末尾的新 describe。
- 两分钟验证:`pnpm --dir ui exec vitest run
packages/components/src/__tests__/page-header-actions.test.tsx`,预期 50
passed,其中 in-flight 一组 7 条。
- 需要你做的:无,席位落地。
## What changes
`PageHeaderActions` (the one resolver behind `page:header`'s row, the
phone bottom-bar face and the shared print-chrome row) now tracks which
header actions have a click in flight.
- `dispatchHeaderAction` returns the runner's `execute` promise instead
of discarding it (both the record and the no-record branch).
- `runHeaderAction(action, key)` calls the host `onClick` or the
dispatch. When the outcome is thenable, the action is pending until that
promise settles, fulfilled or rejected. A ref keyed by action is the
double-click guard; state draws the face.
- While pending, the inline button (row and bar face) stays focusable:
it carries `aria-disabled="true"`, `aria-busy="true"` and
`cursor-progress opacity-50`, and a `Loader2` spinner (the components
package's existing spinner icon) replaces its icon. It is not natively
`disabled`, so a dialog's return-focus call (app-shell's
`useActionDialogReturnFocus`, `opener.focus()` on close) lands on it
while the action is still running (round 1, L1 S1). The ref guard holds
the second click. The `⋯` overflow item keeps Radix `disabled`, because
its `onSelect` keeps the menu open and could be re-selected, and the
menu does not take focus back.
- The declared `disabled`, the inline-edit lock and the disabled-reason
tooltip are unchanged: `disabledReasonFor` still reads only the declared
verdict, so a pending button shows no "not available" reason.
- A host `onClick` that rejects is now reported with `console.error`
naming the action. It used to surface as an unhandled rejection from
`void action.onClick()`.
- No new UI strings.
### Premise, measured by code read on 8e49847
- Runner path: `useAction().execute` (ActionProvider) awaits
`runner.execute` and catches, so it always resolves, never rejects. For
`type: 'flow'` (Convert Lead in `examples/app-crm`), the host's flow
handler (RecordDetailView's `flowHandler` and
`useConsoleActionRuntime`'s `flowDispatch`) awaits `launchConsoleFlow`,
which is the network launch, then calls `setScreenFlow` and returns. So
the promise settles when the screen dialog opens, or on failure, as the
card asks.
- Runner-owned dialogs behave differently: the confirm dialog
(`confirmText`), the param dialog and `type: 'modal'` (`useActionModal`
resolves on close). Their promise spans the dialog. The button stays
busy behind the modal overlay and returns to normal when the dialog
closes. Nothing here never settles.
- Host `onClick` actions: a sync one (Edit) returns no promise and is
never busy. An async one (Delete awaits its confirm) is busy until it
settles.
## Tests
New top-level describe `PageHeaderRenderer — in-flight header action
(objectstack#34933)` in the shared harness
`page-header-actions.test.tsx`:
- busy from the click until the launch resolves; extra clicks do not
dispatch again; a click after settle dispatches again
- normal after the launch rejects
- a host `onClick` that rejects: busy, second click ignored, normal
after reject, failure reported
- a host `onClick` returning nothing is never busy
- the phone bar face: busy, second click ignored, normal after resolve
- round 1: the click guard holds a second and third click on the busy,
still-focusable (`aria-disabled`) button
- round 1: a `confirmText` header action confirmed from the keyboard
with a real `AlertDialog` returns focus to its trigger while the run is
pending, and keeps it after it settles
## Acceptance notes
- Round 1: the ref guard is now the only click guard on the inline face
and is pinned (a second `fireEvent.click` on the busy, `aria-disabled`
button calls the flow once). Ablating it reds 4 / 50 (it was green in
round 0, when native `disabled` swallowed the click).
- Round 1 (L1 S1): a confirmText header action confirmed from the
keyboard now returns focus to its trigger while the run is still
pending, and keeps it after it settles (jsdom pin with a real
`AlertDialog`; the host models app-shell's `useActionDialogReturnFocus`,
since components cannot import app-shell). Restoring native `disabled`
reds that pin at the `activeElement` assertion (body instead of the
button). Radix's own `onCloseAutoFocus` focuses only a `Dialog.Trigger`,
which the console's `ActionConfirmDialog` does not have. A live browser
Convert Lead click is still not taken.
- No live CRM probe was run (throttled-network Convert Lead); the
evidence is code read plus the pins.
- `ui/AGENTS.md` #2 (docs-driven) was not applied: no README or docs
page describes header action button states today.
## Verification
All on head 76c0928 unless noted (the merge of origin/main fff0ad0
touches no file in this diff; the harness was re-run on the merged
head).
<details><summary>Component tests</summary>
- `pnpm --dir ui exec vitest run --maxWorkers=2` on 8 page-header files
(actions, phone-bar, disabledReason x2, actions-shared, pressed, danger,
more-actions-i18n): Test Files 8 passed, Tests 87 passed (on fe9aaee)
- merged head 76c0928: page-header-actions + phone-bar: Test Files 2
passed, Tests 59 passed
- `pnpm --filter @object-ui/components type-check` (`tsc --noEmit && tsc
-p tsconfig.test.json`): exit 0
- eslint on the two touched files: 0 errors (pre-existing
`no-explicit-any` warnings only)
</details>
<details><summary>Ablations (scripts/ablation-replace.mjs, restored blob
== HEAD, git diff HEAD empty)</summary>
- delete `pendingActionKeysRef.current.delete(key);` (settle leg): 4
failed / 44 passed, all four in-flight pins red
- round 0: inline `const disabled = isActionDisabled(action) ||
pending;` to drop `|| pending`: 4 failed / 44 passed
- round 0: guard made dead: 48 passed
- round 1 (head f950825, 8 page-header files: 89 passed): guard made
dead: 4 failed / 46 passed (incl. the second-click pin); native
`disabled` restored (`isActionDisabled(action) || pending`): 6 failed /
44 passed (incl. the focus pin). Report 6959971728.
</details>
<details><summary>Derived gates (dispatch-gates --commands, 38
families)</summary>
- `dispatch-gates --ran`: 38 derived, 38 run, 0 NOT-MEASURED, 0 UNRUN
- 37 exit 0 on fe9aaee's tree. `check:test-source-alias` was red on
the first pass: the new harness import reached the components barrel's
dynamic `import()`. Fixed by importing `page-header-phone-context`
directly, then re-run with exit 0.
- `pnpm --dir ui exec vitest run scripts/` was OOM-killed on the first
pass. Re-run with `--maxWorkers=2`: Test Files 171 passed / 2 skipped,
Tests 5077 passed
- `check:new-line-citations`: 0 new citations
- `overlap-check`: clean exit 0, 0 PR heads
</details>
<!-- signed: repo:objectstack#3 · os-support-ai ·
session_01WGufzgwLiKcfujYUug7sPs -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 421f180 commit db1a05c
3 files changed
Lines changed: 287 additions & 23 deletions
File tree
- .changeset
- ui/packages/components/src
- __tests__
- renderers/layout
| 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 | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
| 10 | + | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
26 | 35 | | |
27 | 36 | | |
28 | 37 | | |
| |||
883 | 892 | | |
884 | 893 | | |
885 | 894 | | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
0 commit comments