Skip to content

Commit 4ab1218

Browse files
fix(console): on a phone the account menu stays on the screen in every language (#36277)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1X6okWxYPWAsooBsJoAhnT1u)_ Fixes #36041 Clause-②: no Metadata-protocol: none ## 维护者速读 - 手机上(768 像素以下)打开右上角头像菜单:以前德、法、俄、西、葡语等界面下菜单比屏幕宽、语言按钮被挤出屏幕右侧点不到;现在菜单不超出屏幕、长句自动换行,语言列表在按钮下方(放不下时在上方)完整打开;电脑宽屏不变。 - 属于手机端外壳的体验修复,替用德语等长文案语言、且浏览器通知被拦截或不支持(如苹果手机浏览器)的手机用户解决。 - 出错的话最多是手机上头像菜单显示得窄一些或换行多一些,不影响数据;只改了一处样式,可直接撤回。 - 无。 ## What changes On a phone the account (avatar) menu sized itself to its longest line, with no width cap. The longest line is the desktop-notification hint, shown whenever notifications are blocked or the browser has no Notification API (Safari on iPhone outside an installed web app). At 375 px with that hint showing, the menu was wider than the screen in seven of the eleven interface languages, and in German, French, Russian, Spanish and Portuguese the Language control sat off the right edge, so the language list could not be opened at all (readings below). - `AccountMenu.tsx`: the menu content gains `max-md:max-w-[calc(100vw-2rem)]`, the screen less a 1 rem gutter on each side, below `md` only. Long lines now wrap and keep their full text (no truncation, so nothing needs a `title`). - From 768 px up nothing changes: the cap is `max-md:`-scoped, and the sidebar-foot trigger from #36187 keeps its placement (above, aligned to the start). **Measured premises (Zone 2 of the dispatch):** 1. The overflowing element is the menu content; the language control overflowed only as a passenger, because it sits inside the menu row. 2. `LocaleSwitcher` is not a side-opening sub-menu: it is its own dropdown anchored to the globe button, opening below it (`data-side=bottom`) and flipping above where only that fits (it does with two organizations listed). Once the globe is back on screen, the list opens on screen in all eleven languages with all eleven rows reachable, so card item 2 is met without changing `LocaleSwitcher`. It is shared with the sign-in page footer (`AuthFooter.tsx`), and this PR leaves it untouched; it already caps its own width at `min(20rem, 100vw - 2rem)`. 3. The cap is local to this menu. The shared `DropdownMenuContent` lives in `packages/components/src/ui/`, which is the upstream no-touch zone, and changing it would change every dropdown; `@object-ui/components` is not touched. The one true sub-menu in this menu, the organization switcher, already renders as inline rows on a phone (`usePhoneViewport` in `WorkspaceSwitcher.tsx`); measured with two organizations, it stays inside the capped menu. Read first, by risk: 1. `ui/packages/app-shell/src/layout/AccountMenu.tsx`, the `DropdownMenuContent` className: the whole behaviour change. 2. `ui/packages/app-shell/src/layout/__tests__/AccountMenu.phoneWidth-36041.test.tsx`: the new pins. 3. `ui/packages/app-shell/src/layout/__tests__/AppHeader.phoneTargets-29075.test.tsx`: its source pin of the same className, updated. ## Tests New file `AccountMenu.phoneWidth-36041.test.tsx` (real Radix menus, real German i18n pack, no component mocks): - the opened account menu carries the phone-only cap, and no unscoped `max-w-*` (desktop unchanged); - the language list opens below or above the globe, never to a side, with one row per platform locale; - each of the eleven rows picks its language (`document.documentElement.lang` after each pick equals the full tag set); - CONTROL: the sidebar trigger's menu keeps `data-side=top`, `data-align=start`. jsdom has no layout, so the cap pin is a class assertion; the layout itself is the browser readings below. `AppHeader.phoneTargets-29075.test.tsx` pinned the old className literally and now pins the new one. Ablation, one run (fix committed first, mutation by `scripts/ablation-replace.mjs`, restored to the HEAD blob): <details><summary>ablation: drop the cap ⇒ 2 red, restore ⇒ HEAD blob</summary> ```text ablation-replace: anchor " max-md:max-w-[calc(100vw-2rem)]" x1 (before) ablation-replace: ok mutation landed: anchor 1 -> 0, blob a216724 -> 3d7346b36ec3 × the account menu (its own module since objectstack#36112), and the theme and language controls inside it × caps the menu at the screen less the gutter below md, and only below md Test Files 2 failed (2) Tests 2 failed | 10 passed (12) ablation-replace: blob after restore a216724 ablation-replace: blob at HEAD a216724 ``` The placement, pick-every-language and desktop-control pins stay green under the ablation, as they should: they pin behaviour the cap does not change in jsdom. </details> ## Acceptance notes - Browser readings are from a throwaway Vite entry (not committed) that mounts the real `AccountMenu` from `ui/` source with stub auth and metadata contexts, the real i18n packs and the console's own CSS, in Chromium at 375 x 812. The full app was not booted: the container has 4 cores shared with other agents and the showcase closure plus the Console build did not fit the session. The harness source is in the evidence folder. - The hint state matters: with notification permission at its default (desktop Chromium), German fits at 272 px and the card's overflow does not show; it shows with permission `denied` (all seven languages) or with no Notification API (German at 374 of 375 px). The readings below use `denied`. - Arabic: the harness shows the menu's rows laid out left-to-right under an RTL document. It fits before and after (0 to 322 px) and this PR does not change it; whether the real Console mirrors the menu was not measured here. ## Verification Two-minute check: on a phone (or devtools at 375 px), set the interface to German, block notifications for the site, open the avatar menu: the menu stays inside the screen, the notification hint wraps onto two lines, and tapping the globe opens the language list under it with all eleven languages. Evidence folder (screenshots before and after, per-language readings, the measuring script and the harness): `/mnt/project-files/pm-orders/objectstack/seat4/a4-H/evidence-36041/` <details><summary>375 px, notifications blocked, before (origin/main a5a5312): menu right edge and the globe</summary> ```text lang menu left..right (width) globe left..right language list en 0..380 (380) 323..367 opens below, 11/11 rows on screen de 0..525 (525) 468..512 globe off screen, cannot open fr 0..476 (476) 419..463 globe off screen, cannot open ru 0..497 (497) 440..484 globe off screen, cannot open es 0..495 (495) 438..482 globe off screen, cannot open pt-BR 0..448 (448) 391..435 globe off screen, cannot open ja 0..416 (416) 359..403 opens below, 11/11 ar 0..322 (322) 265..309 opens below, 11/11 ko 32..367 (336) 310..354 opens below, 11/11 zh-Hans 81..367 (286) 310..354 opens below, 11/11 zh-Hant 81..367 (286) 310..354 opens below, 11/11 ``` </details> <details><summary>375 px, notifications blocked, after: every language on screen, every list opens</summary> ```text lang menu left..right (width) language list en 24..367 (343) below, 11/11 rows on screen de 24..367 (343) below, 11/11 fr 24..367 (343) below, 11/11 ru 24..367 (343) below, 11/11 es 24..367 (343) below, 11/11 pt-BR 24..367 (343) below, 11/11 ar 0..322 (322) below, 11/11 ja 24..367 (343) below, 11/11 ko 32..367 (336) below, 11/11 zh-Hans 81..367 (286) below, 11/11 zh-Hant 81..367 (286) below, 11/11 two organizations (de, ru): menu 24..367, list flips above the globe, 11/11 no Notification API (de, pt-BR): menu 24..367, list below, 11/11 desktop control, 1024 px (de): menu 491..1016 (525), unchanged from today ``` In every run each row was scrolled into view and found on screen, and the last row was tapped and switched the document language; picking each of the eleven rows is the unit test's. </details> <details><summary>Local gates (head db74445)</summary> All at head db74445, every exit code captured before any pipe. ```text dispatch-gates --ran: 38 derived families accounted for, 38 run, 0 NOT-MEASURED (all 38 recorded an exit code: 38 x exit 0) incl. pnpm check:type-check-debt :: exit 0 (re-run inside the verify-lock hold after a first queue-timeout exit 3) incl. pnpm --dir ui exec vitest run scripts/ :: exit 0 (Test Files 172 passed | 2 skipped; Tests 5122 passed | 2 skipped) pnpm --filter '@object-ui/app-shell^...' build :: exit 0 pnpm --filter @object-ui/app-shell run type-check :: exit 0 pnpm --dir ui exec vitest run packages/app-shell/src/layout/ :: exit 0 (Test Files 149 passed; Tests 1129 passed) node scripts/pm/overlap-check.mjs --branch=claude/issue-36041-phone-avatar-menu :: VERDICT clean exit 0 ``` Narrowed and declared: the whole `@object-ui/app-shell` suite and the UI farm are CI's (`Test UI`); locally the `layout/` directory, which holds the changed file and both edited tests, was run. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01FEkQ5oK4fFfnLADcipbEeT)_ Co-authored-by: Claude <noreply@anthropic.com>
1 parent 4099ef2 commit 4ab1218

4 files changed

Lines changed: 165 additions & 3 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
---
4+
5+
fix(console): on a phone the account menu stays on the screen in every interface language
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
The account menu sized itself to its longest line. On a phone, with the desktop notification hint showing (notifications blocked, or a browser with no notification support such as Safari on iPhone), the menu was wider than a 375 px screen in seven of the eleven interface languages (English, German, French, Russian, Spanish, Portuguese, Japanese), and in German, French, Russian, Spanish and Portuguese the Language control was pushed off the right edge, so the language list could not be opened.
11+
12+
Below 768 px the menu is now no wider than the screen less a 1 rem gutter on each side, and long lines wrap with their full text. The language list opens under the Language control (or above it where only that fits), on the screen. From 768 px up the menu is unchanged, and the language list itself, which the sign-in page also uses, is unchanged. No props, exports or locale keys change.

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,18 @@ export function AccountMenu({ trigger }: AccountMenuProps) {
130130
</SidebarMenuButton>
131131
)}
132132
</DropdownMenuTrigger>
133-
{/* 44 px rows below `md`, as the app switcher's menu (objectstack#29075). */}
133+
{/*
134+
* 44 px rows below `md`, as the app switcher's menu (objectstack#29075).
135+
* Below `md` the menu is also no wider than the screen less a 1 rem
136+
* gutter each side: it sizes to its longest line, so an unbounded line
137+
* (a long label, the desktop notification hint in German or Russian)
138+
* would widen it past a phone screen and carry the theme and language
139+
* controls off it. Capped, long lines wrap and keep their full text.
140+
*/}
134141
<DropdownMenuContent
135142
align={trigger === 'avatar' ? 'end' : 'start'}
136143
side={trigger === 'avatar' ? 'bottom' : 'top'}
137-
className="min-w-64 rounded-lg max-md:[&_[role=menuitem]]:min-h-11"
144+
className="min-w-64 rounded-lg max-md:max-w-[calc(100vw-2rem)] max-md:[&_[role=menuitem]]:min-h-11"
138145
sideOffset={4}
139146
>
140147
{/* User identity */}
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* The account menu stays inside a phone screen in every interface language
5+
* (objectstack#36041).
6+
*
7+
* The menu sizes to its longest line. At 375 px, with the desktop notification
8+
* hint showing (a blocked or unsupported Notification API, as on iOS Safari),
9+
* the German, French, Russian, Spanish and Portuguese hints widened it past the
10+
* screen, and the language control rode off the right edge with it: the
11+
* language list could not be opened at all. Below `md` the menu is now capped
12+
* at the screen less a 1 rem gutter each side, so long lines wrap.
13+
*
14+
* The language list is its own dropdown under the globe, opening below it (or
15+
* above, where only that fits), never to the side; with the globe back on the
16+
* screen it opens on the screen. The list itself is shared with the sign-in
17+
* page and is unchanged.
18+
*
19+
* jsdom has no layout, so what is pinned here is what the menu asks for: the
20+
* phone-only cap on the content, the list's placement, and that every language
21+
* row picks its language. The 375 px readings in all eleven languages, before
22+
* and after, are in the pull request.
23+
*/
24+
25+
import '@testing-library/jest-dom/vitest';
26+
import { describe, it, expect, vi, beforeEach } from 'vitest';
27+
import { act, fireEvent, render, screen, waitFor, within } from '@testing-library/react';
28+
import React from 'react';
29+
import { MemoryRouter } from 'react-router-dom';
30+
import { I18nProvider } from '@object-ui/i18n';
31+
import { SidebarProvider } from '@object-ui/components';
32+
import { PLATFORM_LOCALE_TAGS } from '@objectstack/spec/system';
33+
34+
vi.mock('@object-ui/auth', async (importOriginal) => ({
35+
...(await importOriginal<Record<string, unknown>>()),
36+
useAuth: () => ({
37+
user: { id: 'u1', name: 'Lin Yue', email: 'linyue@example.com' },
38+
signOut: vi.fn(),
39+
isAuthEnabled: true,
40+
organizations: [],
41+
activeOrganization: null,
42+
isOrganizationsLoading: false,
43+
getAuthConfig: undefined,
44+
}),
45+
getUserInitials: () => 'LY',
46+
}));
47+
48+
vi.mock('../../providers/MetadataProvider', () => ({
49+
useMetadata: () => ({ apps: [] }),
50+
}));
51+
52+
import { AccountMenu } from '../AccountMenu';
53+
54+
/** The phone-only cap: the screen less a 1 rem gutter each side. */
55+
const PHONE_CAP = 'max-md:max-w-[calc(100vw-2rem)]';
56+
57+
const classesOf = (el: Element) => el.className.split(/\s+/);
58+
59+
function mount(trigger: 'avatar' | 'sidebar', language = 'de') {
60+
const menu = <AccountMenu trigger={trigger} />;
61+
return render(
62+
<I18nProvider config={{ defaultLanguage: language, detectBrowserLanguage: false }} persistLanguage={false}>
63+
<MemoryRouter>{trigger === 'sidebar' ? <SidebarProvider>{menu}</SidebarProvider> : menu}</MemoryRouter>
64+
</I18nProvider>,
65+
);
66+
}
67+
68+
/** Open the account menu from its trigger and return its content. */
69+
function openAccountMenu(): HTMLElement {
70+
const trigger = screen.getAllByRole('button', { name: 'Kontomenü' })[0];
71+
fireEvent.keyDown(trigger, { key: 'Enter' });
72+
return screen.getAllByRole('menu')[0];
73+
}
74+
75+
/** Open the language list from the globe inside the account menu. */
76+
function openLanguageList(menu: HTMLElement): HTMLElement {
77+
const globe = within(menu).getByRole('button', { name: 'Sprache' });
78+
fireEvent.keyDown(globe, { key: 'Enter' });
79+
const menus = screen.getAllByRole('menu');
80+
return menus[menus.length - 1];
81+
}
82+
83+
beforeEach(() => {
84+
document.documentElement.lang = '';
85+
});
86+
87+
describe('the account menu at phone width (objectstack#36041)', () => {
88+
it('caps the menu at the screen less the gutter below md, and only below md', () => {
89+
mount('avatar');
90+
const classes = classesOf(openAccountMenu());
91+
expect(classes).toContain(PHONE_CAP);
92+
// Desktop keeps today's width: no unscoped max width rides on the content.
93+
expect(classes.filter((c) => c.startsWith('max-w-'))).toEqual([]);
94+
});
95+
96+
it('opens the language list below the globe, not to the side', () => {
97+
mount('avatar');
98+
const list = openLanguageList(openAccountMenu());
99+
expect(['bottom', 'top']).toContain(list.getAttribute('data-side'));
100+
expect(within(list).getAllByRole('menuitem')).toHaveLength(PLATFORM_LOCALE_TAGS.length);
101+
});
102+
103+
it('picks every language from the list', async () => {
104+
const { container } = mount('avatar');
105+
const picked: string[] = [];
106+
for (let i = 0; i < PLATFORM_LOCALE_TAGS.length; i++) {
107+
// The trigger is found by its role in the DOM, not its name: the menu
108+
// relabels in each language it picks.
109+
const trigger = container.querySelector('button[aria-haspopup="menu"]');
110+
if (!trigger) throw new Error('no account menu trigger');
111+
fireEvent.keyDown(trigger, { key: 'Enter' });
112+
const menu = screen.getAllByRole('menu')[0];
113+
const globe = within(menu)
114+
.getAllByRole('button')
115+
.find((b) => b.getAttribute('aria-haspopup') === 'menu' && b.querySelector('.lucide-globe'));
116+
if (!globe) throw new Error('no language control in the account menu');
117+
fireEvent.keyDown(globe, { key: 'Enter' });
118+
const menus = screen.getAllByRole('menu');
119+
const rows = within(menus[menus.length - 1]).getAllByRole('menuitem');
120+
expect(rows).toHaveLength(PLATFORM_LOCALE_TAGS.length);
121+
await act(async () => {
122+
fireEvent.click(rows[i]);
123+
});
124+
// Close whatever is still open before the next round.
125+
for (const open of screen.queryAllByRole('menu')) fireEvent.keyDown(open, { key: 'Escape' });
126+
await waitFor(() => expect(screen.queryAllByRole('menu')).toHaveLength(0));
127+
picked.push(document.documentElement.lang);
128+
}
129+
expect([...picked].sort()).toEqual([...PLATFORM_LOCALE_TAGS].sort());
130+
});
131+
132+
it('CONTROL — the desktop sidebar trigger keeps its placement: above, aligned to the start', () => {
133+
mount('sidebar');
134+
fireEvent.keyDown(screen.getByTestId('sidebar-account-menu'), { key: 'Enter' });
135+
const menu = screen.getAllByRole('menu')[0];
136+
expect(menu.getAttribute('data-side')).toBe('top');
137+
expect(menu.getAttribute('data-align')).toBe('start');
138+
});
139+
});

‎ui/packages/app-shell/src/layout/__tests__/AppHeader.phoneTargets-29075.test.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,11 @@ describe('the bar\'s menus and the controls other modules draw (objectstack#2907
273273
});
274274

275275
it('the account menu (its own module since objectstack#36112), and the theme and language controls inside it', () => {
276-
expect(source('AccountMenu.tsx')).toContain(`className="min-w-64 rounded-lg ${PHONE_MENU_ROWS}"`);
276+
// The phone-width cap between the two is objectstack#36041's
277+
// (`AccountMenu.phoneWidth-36041.test.tsx`).
278+
expect(source('AccountMenu.tsx')).toContain(
279+
`className="min-w-64 rounded-lg max-md:max-w-[calc(100vw-2rem)] ${PHONE_MENU_ROWS}"`,
280+
);
277281
for (const file of ['ModeToggle.tsx', 'LocaleSwitcher.tsx']) {
278282
const src = source(file);
279283
expect(src, file).toContain(`className="h-8 w-8 ${PHONE_TARGET}"`);

0 commit comments

Comments
 (0)