Skip to content

Commit 6cc1b3e

Browse files
fix(app-shell): a phone record bar never leads with an Edit that is off, whatever turned it off (#35133)
Fixes #35099 repo:objectstack#1 · os-warren · session_01JQwxbXBffgVtUPBEY2nLFm Clause-②: no Metadata-protocol: none ## 维护者速读 - **改了什么**:手机上的记录页,「编辑」因为任何原因不可用时(对象的 `userActions.edit.disabledWhen` 成立,或记录状态让编辑表单所有字段只读),灰掉的「编辑」都从底部操作栏第一个位置退到「···」菜单里,第一个位置让给能点的动作。之前只有审批锁定时才这样。 - **为什么改**:手机底部第一个位置是主操作位,被一个点不了的「编辑」占着,用户第一眼看到的是灰按钮。 - **风险与回滚**:只改控制台手机端一个条件,不改权限、请求或元数据。桌面端标题行仍把灰掉的「编辑」留在原位(三种原因都有测试钉住),「编辑」可用时完全不变。回滚=还原本 PR。 - **先看**:① `ui/packages/app-shell/src/views/RecordDetailView.tsx` 中 `sys_edit` 的 `editOff` 和 `phonePage && editOff` 一行;② `RecordDetailView.phoneFace-27058.test.tsx` 末尾新增的 describe。 - **两分钟验证**:手机宽度(390)打开一条状态让所有字段只读的记录:右上角有「Not editable in its current state」标记,底部第一个按钮可点,「编辑」在「···」里且是灰的。 - **需要你做的**:无,席位落地。 ## What changes - **Phone bottom bar: an Edit that is off leaves the first slot, for every reason.** The host's Edit is disabled on `approvalLocked || editDisabledByPredicate || editLockedByState`. That expression is now one local, `editOff`, and the phone placement reads it: `...(phonePage && editOff ? { component: 'action:menu' } : {})`. Before, only `approvalLocked` moved Edit into the bar's `⋯`. Edit stays drawn and stays disabled inside the `⋯`, and the bar's queue moves up, so the first declared action takes the slot. - **The promotion needed no change.** The bar draws whatever is not `action:menu` in order, as it already did for the approval case. The new pins measure this for both new reasons. - **Desktop unchanged for every reason.** The `phonePage` gate is untouched, so the desktop header row keeps Edit greyed in place, as #35016 scoped it (pinned below for all three reasons). - **The reason stays readable where one exists.** The state lock keeps its `record-state-lock` badge ("Not editable in its current state"), drawn on the phone too (pinned). The approval lock keeps its band. A `disabledWhen`-disabled Edit has no reason text on any surface, desktop included: `userActions.edit` declares `enabled` / `visibleWhen` / `disabledWhen` and no reason key. What a phone reader sees is the same as on desktop, an "Edit" entry that is off (`aria-disabled="true"`). See Acceptance notes. ## Tests One top-level describe is added to the existing phone harness `RecordDetailView.phoneFace-27058.test.tsx`: "a phone bar never leads with an Edit that is off, for any reason (objectstack#35099)". It mounts a real `RecordDetailView`. The page declares Convert Lead and Assign. - phone (390), `userActions.edit.disabledWhen: "record.status == 'new'"` holding: the bar reads [Convert Lead][Assign][More actions], its first button is enabled, and Edit is in the bar's menu with `aria-disabled="true"`; - phone, `editLockedByState` (every form field carries that `readonlyWhen`): the same bar, the same disabled Edit in the menu, and the state-lock badge is drawn; - control, phone: a `disabledWhen` that does not hold keeps [Edit][Convert Lead][More actions] with Edit enabled; - control, desktop (1440): `disabledWhen`, `editLockedByState` and the approval lock each keep Edit disabled in the header row, and no bottom bar is mounted. The approval-locked phone pin from #35016 is unchanged and still green. The PM route suggested a new file named for this card. Root `AGENTS.md` says a new pin for a component with a shared harness file goes into that file as a top-level `describe`, not a new file. So the block joins the phone harness that already holds the #35016 pin, with its mount helpers. <details><summary>Targeted run, phone harness (code head ffc67c8)</summary> ``` pnpm --dir ui exec vitest run --maxWorkers=2 packages/app-shell/src/views/RecordDetailView.phoneFace-27058.test.tsx Test Files 1 passed (1) Tests 20 passed (20) os-verify-lock: VERDICT command-exit 0 ``` </details> <details><summary>Every RecordDetailView test file in app-shell (code head ffc67c8)</summary> ``` pnpm --dir ui exec vitest run --maxWorkers=2 packages/app-shell/src/views/RecordDetailView packages/app-shell/src/views/__tests__/RecordDetailView Test Files 95 passed (95) Tests 713 passed (713) os-verify-lock: VERDICT command-exit 0 ``` </details> <details><summary>app-shell type-check (head b8e4436; both halves, src and tsconfig.test.json)</summary> ``` pnpm --filter @object-ui/app-shell type-check error TS count: 0 os-verify-lock: VERDICT command-exit 0 ``` `tsc -p tsconfig.test.json --listFiles` lists `RecordDetailView.phoneFace-27058.test.tsx`, so the new block is type-checked. </details> <details><summary>Ablation: the condition put back to the approval lock alone (scripts/ablation-replace.mjs)</summary> The anchor `...(phonePage && editOff ? { component: 'action:menu' } : {}),` was replaced with `...(phonePage && approvalLocked ? { component: 'action:menu' } : {}),`. The anchor went x1 to x0 and the replacement x0 to x1, and the blob went b2305bf to 0931ed4cbccd. The suite resolves `RecordDetailView` from `src` by a relative import, so no build leg applies. ``` × phone, edit.disabledWhen holds: Edit is in the bar's ⋯, off, and Convert Lead leads × phone, editLockedByState: Edit is in the bar's ⋯, off, Convert Lead leads, and the badge states why Tests 2 failed | 18 passed (20) ablation-replace: ok restored: blob == HEAD (b2305bf) and `git diff HEAD` is empty ``` Only the two new phone pins went red. The approval pin, the controls and the desktop pins stayed green, which is expected because the ablation keeps the approval branch and does not touch desktop. </details> ## Acceptance notes - **No reason text for `disabledWhen`.** The card asks that the disabled reason stay readable. For `editLockedByState` and the approval lock it does (the badge and the band). For `edit.disabledWhen`, no reason exists to show on any surface: the spec's `userActions.edit` object has no reason key, and the desktop row shows a greyed Edit with no tooltip either. On a phone the reader gets the same cue as on desktop, an "Edit" entry that is visibly off, now in the `⋯`. No new reason string was invented here. A readable reason would need a declared reason key on `userActions.edit` / `delete` (a spec addition, `Metadata-protocol: added`), which is a contract decision and outside this card. - **The inline-edit draft greying is not moved.** `disableDuringInlineEdit` greys Edit in the `page:header` renderer while an inline draft is live. That state is transient and owned by the renderer, not one of the host's disable reasons, and the card names `disabledWhen` and `editLockedByState`. It is left as it was. - No browser run against a live backend was made for this card. The unit mount covers the bar's order and the disabled overflow entry for each reason. ## Verification Local gate families come from `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` at b8e4436: 39 commands, all exit 0. The `--ran` reconciliation reads "39 derived, 39 run, 0 NOT-MEASURED, 0 UNRUN", with every exit code recorded. Per-command readings are in the dev report on #35099. CI runs the required set. --- _Generated by [Claude Code](https://claude.ai/code/session_01JQwxbXBffgVtUPBEY2nLFm)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent aef42cb commit 6cc1b3e

3 files changed

Lines changed: 131 additions & 9 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
---
4+
5+
fix(app-shell): a phone's record bar never leads with an Edit that is off, whatever turned it off
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
On a phone, the record page's bottom bar moved a greyed Edit out of its first slot only under an approval lock. An Edit turned off by the object's `userActions.edit.disabledWhen`, or by the record's state (every field the edit form shows is read-only through its `readonlyWhen`), still took the first slot, ahead of every action the reader could press. Now Edit moves into the bar's `⋯` for any of the three reasons, still drawn and still off, and the first usable action takes the slot. The state lock keeps its "Not editable in its current state" badge. The desktop header keeps Edit greyed in place for every reason, and an Edit that is on is unchanged.

‎ui/packages/app-shell/src/views/RecordDetailView.phoneFace-27058.test.tsx‎

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,3 +550,113 @@ describe('one ⋯ per screen on a record pending approval (objectstack#35016)',
550550
expect(screen.queryByTestId('declared-actions-decision-menu')).toBeNull();
551551
});
552552
});
553+
554+
/**
555+
* objectstack#35099 — the phone bar's first slot goes to a pressable action
556+
* whatever turns Edit off, not only the approval lock (objectstack#35016,
557+
* pinned above):
558+
*
559+
* - `userActions.edit.disabledWhen` holding on the record;
560+
* - `editLockedByState` — every field the edit form shows read-only by its
561+
* `readonlyWhen` — with its badge still drawn as the reason;
562+
*
563+
* each time Edit sits in the bar's `⋯`, still drawn and still off, and the
564+
* first declared action leads the bar. Controls: the desktop row keeps Edit
565+
* greyed in place for all three reasons, and a `disabledWhen` that does not
566+
* hold leaves Edit leading the bar, pressable.
567+
*/
568+
const LOCKS_NEW = "record.status == 'new'";
569+
570+
/** The fixtures' object list, widened by one key the page reads; `mountPage` only passes it through. */
571+
type PageObjects = Parameters<typeof mountPage>[1];
572+
573+
function leadWithDisabledEdit(when: string): PageObjects {
574+
const [lead, ...rest] = objectsWith([action('convert', 'Convert Lead'), action('assign', 'Assign')]);
575+
return [{ ...lead, userActions: { edit: { disabledWhen: when } } }, ...rest] as never;
576+
}
577+
578+
function leadLockedByState(): PageObjects {
579+
const [lead, ...rest] = objectsWith([action('convert', 'Convert Lead'), action('assign', 'Assign')]);
580+
const fields = Object.fromEntries(
581+
Object.entries(lead.fields).map(([name, def]) => [name, name === 'id' ? def : { ...def, readonlyWhen: LOCKS_NEW }]),
582+
);
583+
return [{ ...lead, fields }, ...rest] as never;
584+
}
585+
586+
/** The desktop header row's Edit, read before any menu opens. */
587+
async function desktopRowEdit(): Promise<HTMLButtonElement> {
588+
return waitFor(
589+
() => {
590+
const header = document.querySelector('[data-record-page-root] header') as HTMLElement | null;
591+
expect(header).toBeTruthy();
592+
const row = within(header!).getByRole('toolbar');
593+
const edit = within(row).getAllByRole('button').find((b) => b.textContent?.trim() === 'Edit');
594+
expect(edit).toBeTruthy();
595+
return edit as HTMLButtonElement;
596+
},
597+
{ timeout: 5000 },
598+
);
599+
}
600+
601+
async function expectEditInBarOverflowOff() {
602+
await barDrawn();
603+
await waitFor(() => expect(barButtons()).toEqual(['Convert Lead', 'Assign', 'More actions']));
604+
const first = actionBar()!.querySelector('[role="toolbar"] button') as HTMLButtonElement;
605+
expect(first.disabled).toBe(false);
606+
fireEvent.pointerDown(within(actionBar()!).getByRole('button', { name: 'More actions' }), { button: 0, ctrlKey: false, pointerType: 'mouse' });
607+
const menu = await screen.findByRole('menu');
608+
const edit = within(menu).getAllByRole('menuitem').find((i) => i.textContent?.trim() === 'Edit');
609+
expect(edit).toBeTruthy();
610+
expect(edit!.getAttribute('aria-disabled')).toBe('true');
611+
}
612+
613+
describe('a phone bar never leads with an Edit that is off, for any reason (objectstack#35099)', () => {
614+
beforeEach(() => {
615+
__resetRecordApprovalsStore();
616+
});
617+
618+
it('phone, edit.disabledWhen holds: Edit is in the bar\'s ⋯, off, and Convert Lead leads', async () => {
619+
mountPage([`/apps/${APP}/${LEAD}/record/r-1`], leadWithDisabledEdit(LOCKS_NEW));
620+
await expectEditInBarOverflowOff();
621+
});
622+
623+
it('phone, editLockedByState: Edit is in the bar\'s ⋯, off, Convert Lead leads, and the badge states why', async () => {
624+
mountPage([`/apps/${APP}/${LEAD}/record/r-1`], leadLockedByState());
625+
await waitFor(() => expect(screen.getByTestId('record-state-lock').textContent).toBe('Not editable in its current state'), { timeout: 5000 });
626+
await expectEditInBarOverflowOff();
627+
});
628+
629+
it('control, phone: a disabledWhen that does not hold keeps [Edit][Convert Lead][⋯] with Edit pressable', async () => {
630+
mountPage([`/apps/${APP}/${LEAD}/record/r-1`], leadWithDisabledEdit("record.status == 'closed'"));
631+
await barDrawn();
632+
await waitFor(() => expect(barButtons()).toEqual(['Edit', 'Convert Lead', 'More actions']));
633+
const first = actionBar()!.querySelector('[role="toolbar"] button') as HTMLButtonElement;
634+
expect(first.disabled).toBe(false);
635+
});
636+
637+
it('control, desktop: edit.disabledWhen keeps Edit greyed in place in the header row', async () => {
638+
setWidth(1440);
639+
mountPage([`/apps/${APP}/${LEAD}/record/r-1`], leadWithDisabledEdit(LOCKS_NEW));
640+
const edit = await desktopRowEdit();
641+
await waitFor(() => expect(edit.disabled).toBe(true));
642+
expect(actionBar()).toBeNull();
643+
});
644+
645+
it('control, desktop: editLockedByState keeps Edit greyed in place in the header row', async () => {
646+
setWidth(1440);
647+
mountPage([`/apps/${APP}/${LEAD}/record/r-1`], leadLockedByState());
648+
const edit = await desktopRowEdit();
649+
await waitFor(() => expect(edit.disabled).toBe(true));
650+
expect(actionBar()).toBeNull();
651+
});
652+
653+
it('control, desktop: the approval lock keeps Edit greyed in place in the header row', async () => {
654+
setWidth(1440);
655+
stubApprovals(PENDING_REQUEST);
656+
mountApprovalPage();
657+
await screen.findByTestId('declared-actions-decision-menu', undefined, { timeout: 5000 });
658+
const edit = await desktopRowEdit();
659+
await waitFor(() => expect(edit.disabled).toBe(true));
660+
expect(actionBar()).toBeNull();
661+
});
662+
});

‎ui/packages/app-shell/src/views/RecordDetailView.tsx‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4720,6 +4720,7 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri
47204720
} as any);
47214721
}
47224722
if (affordances.edit) {
4723+
const editOff = approvalLocked || editDisabledByPredicate || editLockedByState;
47234724
// Single primary Edit CTA → opens the full record form. Inline editing
47244725
// is no longer a standalone header button; it is entered by
47254726
// double-clicking a field (or its hover pencil) in the record body,
@@ -4765,15 +4766,16 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri
47654766
// edit form is a third reason for the same off, explained beside the
47664767
// header by the `editLockedByState` badge, as the lock band explains
47674768
// the approval lock.
4768-
disabled: approvalLocked || editDisabledByPredicate || editLockedByState,
4769-
// objectstack#35016 — on a phone the bottom bar's first slot is its
4770-
// primary place, and an action that cannot be pressed never holds
4771-
// it: under the approval lock this Edit moves into the bar's `⋯`
4772-
// (still drawn, still off), and the first usable action takes the
4773-
// slot. The approval band above states the lock. The desktop row
4774-
// keeps it greyed in place, and a record with no approval lock is
4775-
// untouched.
4776-
...(phonePage && approvalLocked ? { component: 'action:menu' } : {}),
4769+
disabled: editOff,
4770+
// objectstack#35016, objectstack#35099 — on a phone the bottom bar's
4771+
// first slot is its primary place, and an action that cannot be
4772+
// pressed never holds it: whichever of the three reasons above turns
4773+
// this Edit off, it moves into the bar's `⋯` (still drawn, still
4774+
// off), and the first usable action takes the slot. The approval band
4775+
// states the lock, and the `editLockedByState` badge the state lock.
4776+
// The desktop row keeps it greyed in place for every reason, and an
4777+
// Edit that is on is untouched.
4778+
...(phonePage && editOff ? { component: 'action:menu' } : {}),
47774779
onClick: () => onEdit({ id: pureRecordId }, objectName),
47784780
} as any);
47794781
}

0 commit comments

Comments
 (0)