Skip to content

Commit aef42cb

Browse files
fix(app-shell): the phone bar lights More when the page in view lives behind it (#35130)
Fixes #35020 Clause-②: no Metadata-protocol: none ## 维护者速读 - **改了什么**:手机端底部菜单栏:当前页面的菜单项不在底部四项里、但在「更多」打开的完整菜单里时,「更多」高亮;在四项里时照旧高亮那一项,「更多」不高亮。「更多」打开后当前项的选中态,实测在 main 上本来就有,本 PR 只加测试钉住,没有改抽屉。 - **为什么改**:在「商机」这类不在底部四项里的页面,底部五项都不亮,用户看不出自己在哪个菜单(卡上 375×812 实测)。 - **风险与回滚**:只改 `PhoneAppNavBar.tsx` 里「更多」的高亮判定(20 行增、5 行删),不改底部四项的取法,不改元数据、接口或导出。没有任何菜单项对应的页面不亮任何一项(「更多」亮着就承诺点开后有选中的那一行)。回滚即还原本 PR。 - **先看**:`ui/packages/app-shell/src/layout/PhoneAppNavBar.tsx` 的 `currentBehindMore` 判定和「更多」按钮上的 `aria-current`;`ui/packages/app-shell/src/layout/__tests__/UnifiedSidebar.phoneNavBar-34594.test.tsx` 新增的 describe。 - **两分钟验证**:`pnpm --dir ui exec vitest run packages/app-shell/src/layout/__tests__/UnifiedSidebar.phoneNavBar-34594.test.tsx`,预期 16 个用例全绿;或在 375 宽打开 HotCRM 销售应用(不固定任何菜单项)的「商机」列表,底部「更多」高亮,点开后「商机」一行是选中态;切到「线索」列表,亮的是「线索」,「更多」不亮。 - **需要你做的**:无,席位落地。 ## What changes - `PhoneAppNavBar` still elects the page's row the way the drawer does (`resolveActiveNavItem` over the whole tree) and still lights an entry cell only when that row is the cell's entry. New: when the elected row is drawn in the full menu (`drawnNavigationEntries` under the sidebar's own guards) but holds no bar cell, 「More」 takes the lit look (`text-primary`) and `aria-current="true"`. At most one cell is ever lit. - A page that elects no row, or elects a row the menu does not draw (a `visible: false` entry reached by URL), lights no cell, More included: More lit says the menu behind it has the page's row selected, and there would be none. - While the full menu is open, More stays lit for the open menu and no cell carries `aria-current` (unchanged for entry cells; More follows the same rule). - **`aria-current="true"`, not `"page"`, on More:** the cell is a button that opens the menu holding the page's row, not a link to the page; `"page"` would announce the button itself as the current page. ARIA's `true` token is "the current item within a set" when no specific token fits. The entry cells keep `aria-current="page"`: they are links to the page. - **Item 2 of the card (the opened menu selects the current row) was already met on `958ee035`**, measured before any code change (see Verification): the drawer's `NavigationRenderer` elects the same row, draws `data-active="true"` on it, and opens the group holding it. No drawer change; the pins hold it. - **Public surface:** no prop added. `PhoneAppNavBar` is not re-exported by `ui/packages/app-shell/src/layout/index.ts`, so the package entry does not carry it; the claim's `Clause-②: no` holds by that reading. - Changeset `.changeset/35020-phone-bar-more-active.md`, `@object-ui/app-shell: patch` (the precedent the other app-shell fixes this week follow). ## Tests A new top-level `describe` in the existing shared harness `UnifiedSidebar.phoneNavBar-34594.test.tsx`, not a new file: AGENTS.md's test discipline sends a new pin for a component that already has a shared harness file into that file (ruling record 6583487846). The harness renders the real `UnifiedSidebar`, `SidebarProvider` and `@object-ui/layout` at 375 px. - Acceptance line 1, two setups: pins put Opportunities off the bar (the card's 「商机」 shape), and nothing pinned with My tasks as the fifth entry (the card's "用户没有固定任何菜单项"). Each asserts the lit cells are exactly More, More carries `aria-current="true"`, no entry carries `aria-current="page"`; then opens More and asserts the menu's selected rows are exactly that row, More is `aria-expanded` and still the one lit cell. - Acceptance line 2: on the Leads page the lit cells are exactly Leads (with `aria-current="page"`), More carries no `aria-current`; opened, More is the one lit cell and the menu selects Leads. - CONTROL, two rows: a page whose elected row the menu does not draw, and a page no entry addresses, light no cell and carry no `aria-current`. ## Acceptance notes - The card's reader names `ui/packages/layout/src/AppSchemaRenderer.tsx`; the bar that shipped lives in `ui/packages/app-shell/src/layout/PhoneAppNavBar.tsx`, as the claim's premise corrected. - The file surface the claim declared named new test files for this card; the pins went into the existing harness file instead, by the AGENTS.md rule above. `overlap-check.mjs` found no open PR sharing a file with this branch. - Not done, per the card's 不做的: the bar's four entries are chosen as before (pinned first, then the menu's first entries); no replacement by recent use. - Pre-existing, untouched: eslint's `react-refresh/only-export-components` warning on the existing `phoneNavBarEntries` export in `PhoneAppNavBar.tsx`. ## Verification All readings on `facd9cb9` (the final commit), `objectstack-ai/objectstack`, worktree off `958ee035`; timings are shared-box seconds under the verify lock. <details><summary>Measurement on unchanged bar code (pins committed first, fix not yet written)</summary> - `vitest run UnifiedSidebar.phoneNavBar-34594.test.tsx` on `0e82f3d6` (pins only): `Tests 2 failed | 14 passed (16)`, both failures the acceptance-1 rows at `expected [] to deeply equal [ 'More' ]` (no cell lit, More not lit). - Item 2 alone: the same two rows with the bar assertions removed in the working tree (restored by `git checkout HEAD`, blob back to `ef2ccdaf`, `git diff HEAD` empty): `Tests 2 passed | 14 skipped (16)` — the opened menu selects exactly the page's row on unchanged code. </details> <details><summary>Tests, typecheck, ablation</summary> - `pnpm --dir ui exec vitest run packages/app-shell/src/layout/__tests__/UnifiedSidebar.phoneNavBar-34594.test.tsx`: `Tests 16 passed (16)`, VERDICT command-exit 0. - The 33 `UnifiedSidebar.*`, `ConsoleLayout.*` and `usePhoneNavDrawerHistory-29131` files under `ui/packages/app-shell/src/layout/__tests__/`: `Test Files 33 passed (33)`, `Tests 183 passed (183)`. The full app-shell suite runs in CI (Test UI); not run locally. - `pnpm --filter @object-ui/app-shell type-check` (both programs; `tsconfig.test.json` includes `src/**/*.test.tsx`): VERDICT command-exit 0, after building the app-shell dependency closure. - Ablation 1 (`node scripts/ablation-replace.mjs`, anchor hit 1, blob `d772853b` to `0c918a5c`): More lit only while the menu is open, as on main: `Tests 2 failed | 14 passed (16)`, the acceptance-1 rows. Restored: blob equals HEAD, `git diff HEAD` empty. - Ablation 2 (anchor hit 1, blob `d772853b` to `77c6b7d1`): the drawn-row guard dropped: `Tests 1 failed | 15 passed (16)`, the CONTROL row for an undrawn entry (`expected [ 'More' ] to deeply equal []`). Restored: blob equals HEAD, `git diff HEAD` empty. - No `dist` in the path: the harness imports `../UnifiedSidebar` relatively and `@object-ui/*` resolves to source through the ui vitest aliases. </details> <details><summary>Gates (derived by dispatch-gates.mjs --commands on this diff)</summary> - 38 derived families, every one run on `facd9cb9`, each exit 0; `dispatch-gates.mjs --ran` answers `38 derived, 38 run, 0 NOT-MEASURED, 0 UNRUN` (a derived zero: every line recorded its exit code). - Includes `pnpm --dir ui exec vitest run scripts/` (`Test Files 171 passed | 2 skipped (173)`), `pnpm check:type-check-coverage`, `pnpm check:type-check-debt`, `pnpm check:nul-bytes`, `pnpm check:published-files`, `pnpm check:test-source-alias`, the changeset gates and the closing-keyword parity pair. - Also: `node ui/scripts/check-new-cross-file-line-citations.mjs`: `0 new citation(s)`; control-byte scan of the three changed files: no hit. - `node scripts/pm/overlap-check.mjs`: `VERDICT clean exit 0` (merges cleanly with `origin/main`, 0 open PR heads share a file). - The repo-wide farm is CI's. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01JQwxbXBffgVtUPBEY2nLFm)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 4ffe9d3 commit aef42cb

3 files changed

Lines changed: 90 additions & 5 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 bottom menu bar lights More when the page in view is in the full menu but not in the bar
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
On a phone, the bottom menu bar holds four of the app's entries and then More, which opens the full menu. On a page whose entry was not one of the four (an Opportunities list when the bar holds Home, Sales home, Leads and Accounts), no cell was highlighted, so the bar did not show where the reader was. More is now highlighted on such a page, and the full menu it opens shows that entry selected. On a page whose entry is one of the four, that cell is highlighted as before and More is not. A page that no menu entry addresses highlights no cell. Which four entries the bar holds is unchanged: pinned entries first, then the menu's first entries.

‎ui/packages/app-shell/src/layout/PhoneAppNavBar.tsx‎

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
* sidebar's own (already pruned of entries the member may not read), walked by
1818
* `drawnNavigationEntries`, the sidebar's guard statement and order rule.
1919
* A cell opens what its drawer row opens (`resolveHref`), and lights when
20-
* that row lights (`resolveActiveNavItem`).
20+
* that row lights (`resolveActiveNavItem`). When the row that lights is drawn
21+
* in the full menu but holds no cell, 「More」 lights in its place
22+
* (objectstack#35020): one cell at most is lit, and it is the way back to the
23+
* page in view.
2124
*
2225
* The console layout decides where the bar is mounted: on a phone, inside an
2326
* app, never on a record page or a record form, whose bottom edge belongs to
@@ -129,9 +132,18 @@ export function PhoneAppNavBar({
129132
const entries = phoneNavBarEntries(items, pinnedIds, guards, hasAddress);
130133
// The row the drawer lights, elected over the whole tree as the drawer
131134
// elects it, so at most one cell lights and it is that row.
132-
const activeId = menuOpen
133-
? null
134-
: resolveActiveNavItem(items, location.pathname, location.search, basePath, templateContext)?.id ?? null;
135+
const currentId =
136+
resolveActiveNavItem(items, location.pathname, location.search, basePath, templateContext)?.id ?? null;
137+
const activeId = menuOpen ? null : currentId;
138+
// A row the full menu draws but no cell holds lights 「More」, the cell that
139+
// opens it. A page no drawn row addresses lights nothing: 「More」 lit says
140+
// the menu behind it has the page's row selected. While the menu is open,
141+
// 「More」 is lit for the open menu and the bar marks no page.
142+
const currentBehindMore =
143+
currentId !== null &&
144+
!entries.some((entry) => entry.id === currentId) &&
145+
drawnNavigationEntries(items, guards).some((entry) => entry.id === currentId);
146+
const moreMarksPage = !menuOpen && currentBehindMore;
135147
const moreLabel = t('common.more', { defaultValue: 'More' });
136148

137149
return (
@@ -179,8 +191,11 @@ export function PhoneAppNavBar({
179191
onClick={onOpenMenu}
180192
aria-haspopup="dialog"
181193
aria-expanded={menuOpen}
194+
// `true`, not `page`: the button is where the page in view lives,
195+
// not a link to it.
196+
aria-current={moreMarksPage ? 'true' : undefined}
182197
data-testid="phone-app-nav-more"
183-
className={cn(CELL_CLASS, menuOpen ? 'text-primary' : 'text-muted-foreground')}
198+
className={cn(CELL_CLASS, menuOpen || moreMarksPage ? 'text-primary' : 'text-muted-foreground')}
184199
>
185200
<MoreHorizontal className="h-5 w-5 shrink-0" aria-hidden />
186201
<span className="max-w-full truncate">{moreLabel}</span>

‎ui/packages/app-shell/src/layout/__tests__/UnifiedSidebar.phoneNavBar-34594.test.tsx‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,66 @@ describe('the phone bottom menu bar (objectstack#34594)', () => {
252252
});
253253
});
254254

255+
describe('the bar shows where the page in view lives: its cell, else More (objectstack#35020)', () => {
256+
/** The bar's lit cells (entries, then More), as their labels read. */
257+
function litCells(): string[] {
258+
const bar = screen.getByTestId('phone-app-nav-bar');
259+
return [
260+
...within(bar).queryAllByTestId('phone-app-nav-cell'),
261+
within(bar).getByTestId('phone-app-nav-more'),
262+
]
263+
.filter((cell) => cell.classList.contains('text-primary'))
264+
.map((cell) => cell.textContent ?? '');
265+
}
266+
267+
/** Opens the full menu and answers the labels of its selected rows. */
268+
async function openMenuSelectedRows(): Promise<string[]> {
269+
fireEvent.click(screen.getByTestId('phone-app-nav-more'));
270+
const menu = await screen.findByRole('dialog');
271+
return Array.from(menu.querySelectorAll('[data-sidebar="menu-button"][data-active="true"]')).map(
272+
(row) => row.textContent ?? '',
273+
);
274+
}
275+
276+
it.each([
277+
{ setup: 'pins put the page\'s entry off the bar', pins: ['n_tasks', 'n_perf'], path: '/apps/sales/opportunity', row: 'Opportunities' },
278+
{ setup: 'nothing pinned, the page is the fifth entry', pins: [], path: '/apps/sales/task', row: 'My tasks' },
279+
])('a page whose entry is not one of the four lights More; the full menu selects its row ($setup)', async ({ pins, path, row }) => {
280+
renderSidebar({ path, pins });
281+
expect(barCells()).not.toContain(row);
282+
expect(litCells()).toEqual(['More']);
283+
const more = screen.getByTestId('phone-app-nav-more');
284+
expect(more).toHaveAttribute('aria-current', 'true');
285+
expect(screen.getByTestId('phone-app-nav-bar').querySelector('[aria-current="page"]')).toBeNull();
286+
287+
expect(await openMenuSelectedRows()).toEqual([row]);
288+
// Open, More is lit for the open menu, and it is still the one lit cell.
289+
expect(more).toHaveAttribute('aria-expanded', 'true');
290+
expect(litCells()).toEqual(['More']);
291+
});
292+
293+
it('a page whose entry is one of the four lights that cell, not More', async () => {
294+
renderSidebar({ path: '/apps/sales/lead' });
295+
expect(litCells()).toEqual(['Leads']);
296+
const bar = screen.getByTestId('phone-app-nav-bar');
297+
expect(within(bar).getByRole('link', { name: 'Leads' })).toHaveAttribute('aria-current', 'page');
298+
expect(screen.getByTestId('phone-app-nav-more')).not.toHaveAttribute('aria-current');
299+
300+
// Open, More is the one lit cell, and the full menu selects the same row.
301+
expect(await openMenuSelectedRows()).toEqual(['Leads']);
302+
expect(litCells()).toEqual(['More']);
303+
});
304+
305+
it.each([
306+
{ setup: 'an entry the menu does not draw', path: '/apps/sales/secret' },
307+
{ setup: 'no entry at all', path: '/apps/sales/product' },
308+
])('CONTROL — a page that addresses $setup lights no cell, More included', ({ path }) => {
309+
renderSidebar({ path });
310+
expect(litCells()).toEqual([]);
311+
expect(screen.getByTestId('phone-app-nav-bar').querySelector('[aria-current]')).toBeNull();
312+
});
313+
});
314+
255315
describe('phoneNavBarEntries (objectstack#34594)', () => {
256316
const always = () => true;
257317
const entries = (pins: string[], items: NavigationItem[] = NAV) =>

0 commit comments

Comments
 (0)