Skip to content

Commit 0189004

Browse files
fix(app-shell): the chart view's view bar starts its icon on the list page's 16px edge (#35826)
<!-- claude-projects-attribution: {"github_login":"os-bill"} --> _Requested by **Bill** · [project thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wgEV9LRY8FfTWS7J6T3MwsSL)_ Fixes #35729 repo:objectstack#5 · os-bill · session_01Utp6Cb8qTxAVaE2QKwquQU Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:宽屏下图表视图的视图栏图标和列表视图一样离左边 16,在列表和图表之间切换时视图切换器不再左右跳;手机宽度不变。 - 为什么做:#35663 把列表视图栏对齐到 16 后,图表视图自己那份视图栏还留在 22,是 #35663 的 L1 记录里留下的后续项。 - 出错会怎样:只改图表视图栏的内边距,并删掉一个已经没人读的内部参数,不动数据和权限;有问题可以直接撤回。 - 要你做什么:无 ## What changes - **The chart view's view bar takes the list view bar's padding** (`objectViewListRenderer.tsx`, `chartPage`): `sm:px-4` becomes `sm:pl-2.5 sm:pr-2`, the same values as `TOOLBAR_ROW` in `plugin-list`'s `listToolbarRow.ts` (not imported: `plugin-list`'s index does not export the constant, and exporting it was outside the claim). From `sm` up the switcher's 6px-padded icon lands on 16, where the list's does. Below `sm` both bars keep `px-2`, so 375 is unchanged. - **The idle `inSetup` input goes end to end** (claim amendment 2, 7036258221). Since #35663 removed the Setup app's row-number line, `useObjectViewListRenderer` read it only in the `renderListView` memo's dependency list. Removed: that dependency, the destructured prop and its type, the type-only `isSetupAppSegment` import (renderer); the derivation, its stale objectui#12606 comment, its pass and the `isSetupAppSegment` import (`ObjectView.tsx`). Remaining readers: none in either file. Other `inSetup` / `isSetupAppSegment` readers in app-shell (`ResourceListPage`, `RecordDetailView`) are their own and untouched. ## Tests - `ui/e2e/list-left-edge-35663.spec.ts` (#35663's geometry spec) gains a chart view bar: its class is read out of `objectViewListRenderer.tsx` at run time (the `chartPage` bar), and a second bar with that class, holding the real switcher class, sits under the list's view bar. At 1280 (wide and narrow cases) its icon is on the 16 edge and on the list view's icon (±1), and its right padding equals the list bar's; at 375 its icon equals the list's (and ≥12). - Ablation: with the bar's class put back to `sm:px-4`, the two 1280 cases go red (`chart view-bar icon starts at 22, not 16`); 375 and the scroll case stay green, as they should. - No unit test added: no vitest reads the chart bar's class or `inSetup` (grep over `ui/packages/*/src` for `inSetup`, `isSetupAppSegment` and `sm:px-4 sm:py-0` beside `ObjectView` / `objectViewListRenderer`: 0 hits), and jsdom has no layout for the padding. ## Acceptance notes Readings (the e2e harness, main area 1024 wide beside a 256 sidebar at 1280; x from the main area's left): | | list view icon | chart view icon | list bar right padding | chart bar right padding | |---|---|---|---|---| | main 65fddc8, 1280 | 16 | 22 | 8 | 16 | | this PR, 1280 (wide and narrow) | 16 | 16 | 8 | 8 | | main, 375 | 14 | 14 | — | — | | this PR, 375 | 14 | 14 | — | — | - The chart bar draws only the switcher, so "right edge 16" reads as the bar's right padding equal to the list bar's 8 (the list's last trigger adds its own 8 to reach 16). - Platform checklist: not edited. `records-forms.list-view-capabilities` steps[11] (from #35663) states the list page's left edge; a chart-view sentence there would be outside the claim's surface. carrier: none. Screenshots (1280 narrow, 1280 wide, 375; the fixture's icons are blank 16px boxes): `objectstack-seat5/area-ux/ux-4/chart/card-35729/` in the project files. ## Verification Read first: `ui/packages/app-shell/src/views/objectViewListRenderer.tsx`, the `chartPage` bar class; then the `inSetup` removal in the same file and `ObjectView.tsx`. Two-minute check: open an object with a chart view at 1280, switch between a list view and the chart view; the view switcher's icon stays put. <details><summary>Local readings</summary> - Geometry spec: 4 passed at this head; ablated, 2 of 4 red as above. - `pnpm --filter @object-ui/app-shell type-check`: exit 0 (after `pnpm --filter '@object-ui/app-shell^...' build`). - `vitest run packages/app-shell/src/views/ObjectView.`: 93 files, 826 tests passed. - `node scripts/pm/dispatch-gates.mjs --commands`: 38 commands derived, all exit 0 (log `gates-ran.log` beside the screenshots) - `node scripts/pm/overlap-check.mjs --branch=HEAD`: clean (origin/main merges cleanly; #35747 shares `objectViewListRenderer.tsx`, merges cleanly). </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Utp6CasQ2sQyph6xUMdArZ <!-- signed: repo:objectstack#5 · os-bill · session_01Utp6Cb8qTxAVaE2QKwquQU --> Co-authored-by: Claude <noreply@anthropic.com>
1 parent e7627e2 commit 0189004

4 files changed

Lines changed: 58 additions & 15 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: a chart view's view bar starts its view icon on the list page's 16px left edge, as the list view's bar does
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
A chart view draws its own copy of the view bar, and that copy kept `sm:px-4` after the list view's bar moved to `sm:pl-2.5 sm:pr-2` in #35663. From `sm` up the chart's view icon sat 22px from the main area's left edge while the list's sat at 16, so switching between a list view and a chart view moved the switcher. The chart bar now carries the list bar's padding: at 1280 its icon starts at 16 and its right padding is the list bar's 8. Below `sm` both bars keep `px-2`, so a phone is unchanged.
11+
12+
The list renderer's `inSetup` input is gone. Since #35663 removed the Setup app's row-number line it was read only in a memo's dependency list, so `ObjectView` no longer derives it from the route.

‎ui/e2e/list-left-edge-35663.spec.ts‎

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ import { uiRoot } from '../scripts/ui-root.mjs';
4949
* the switcher's and footer's contents are short literals. Fonts are
5050
* Chromium's fallbacks: the assertions are edges and widths of boxes, not of
5151
* glyphs.
52+
*
53+
* ## The chart view's view bar (objectstack#35729)
54+
*
55+
* A chart view draws its own copy of the view bar (`chartPage` in
56+
* `objectViewListRenderer.tsx`), which kept `sm:px-4` after #35663 and so put
57+
* the view icon at 22. Its class is read out of that file at run time and a
58+
* second bar with that class, holding the same switcher, sits under the list's
59+
* view bar: at 1280 its icon starts on the list's 16 and its right padding is
60+
* the list bar's; at 375 it is no closer than 12 to the left edge.
5261
*/
5362

5463
const REPO_ROOT = uiRoot();
@@ -76,6 +85,11 @@ const SWITCHER_CLASS = pick(
7685
/data-testid="list-view-switcher"[\s\S]*?className=\{cn\(\s*(?:\/\/[^\n]*\n\s*)*'([^']+)'/,
7786
'the switcher trigger class',
7887
);
88+
const CHART_BAR_CLASS = pick(
89+
'packages/app-shell/src/views/objectViewListRenderer.tsx',
90+
/const chartPage = [\s\S]*?hasPhoneTitle && \(\s*<div className="([^"]+)"/,
91+
'the chart view bar class',
92+
);
7993
const FOOTER_CLASS = pick(
8094
'packages/plugin-list/src/ListView.tsx',
8195
/className="([^"]+)"\s*data-testid="record-count-bar"/,
@@ -100,6 +114,7 @@ interface Case {
100114
sidebar: number;
101115
columns: string[];
102116
switcherClass: string;
117+
chartBarClass: string;
103118
footerClass: string;
104119
}
105120

@@ -178,6 +193,8 @@ createRoot(document.getElementById('root')).render(
178193
h('button', { id: 'switcher', className: c.switcherClass }, box16('view-icon'), h('span', { className: 'truncate' }, 'All contacts')))),
179194
h('div', { id: 'cluster', className: Row.TOOLBAR_CLUSTER },
180195
...['Filter', 'Sort', 'Options'].map((l) => h('button', { key: l, className: 'bar-button inline-flex items-center ' + Row.TOOLBAR_TEXT_TRIGGER }, l)))),
196+
h('div', { id: 'chartbar', className: c.chartBarClass },
197+
h('button', { id: 'chart-switcher', className: c.switcherClass }, box16('chart-view-icon'), h('span', { className: 'truncate' }, 'Pipeline chart'))),
181198
h('div', { className: 'flex min-h-0 flex-1 flex-col' },
182199
h(ObjectGrid, {
183200
dataSource,
@@ -277,12 +294,12 @@ async function styleUntilStable(page: Page, compiled: Set<string>): Promise<void
277294
}
278295

279296
/** Mount the case, style it, and wait until the table's geometry holds still. */
280-
async function mount(page: Page, c: Omit<Case, 'switcherClass' | 'footerClass'>): Promise<void> {
297+
async function mount(page: Page, c: Omit<Case, 'switcherClass' | 'chartBarClass' | 'footerClass'>): Promise<void> {
281298
await page.setViewportSize({ width: c.viewport, height: 800 });
282299
await page.setContent('<!doctype html><html><head><style>html,body{margin:0}</style></head><body><div id="root"></div></body></html>');
283300
await page.evaluate((value) => {
284301
(window as unknown as { __case: Case }).__case = value;
285-
}, { ...c, switcherClass: SWITCHER_CLASS, footerClass: FOOTER_CLASS });
302+
}, { ...c, switcherClass: SWITCHER_CLASS, chartBarClass: CHART_BAR_CLASS, footerClass: FOOTER_CLASS });
286303
await page.addScriptTag({ content: bundle, type: 'module' });
287304
// Below 768 the grid draws cards, not a table.
288305
await page.locator('tbody [role="checkbox"], [data-testid="grid-mobile-card"]').first().waitFor({ state: 'attached', timeout: 30_000 });
@@ -309,6 +326,8 @@ interface Reading {
309326
left: {
310327
pageIcon: number;
311328
viewIcon: number;
329+
/** The chart view's view bar (objectstack#35729). */
330+
chartViewIcon: number;
312331
headerCheckbox: number;
313332
rowCheckboxes: number[];
314333
footerText: number;
@@ -317,6 +336,8 @@ interface Reading {
317336
};
318337
/** Right edges, from the main area's right (distance in): the page bar's button box, the view bar's last label. */
319338
right: { pageAction: number; viewCluster: number; footer: number; scrollBox: number };
339+
/** The right padding of the list's view bar and of the chart view's (objectstack#35729). */
340+
barPaddingRight: { list: number; chart: number };
320341
/** The selection column's header cell: width and drawn left, from the main area. */
321342
selection: { width: number; left: number };
322343
rowNumbers: number;
@@ -363,6 +384,7 @@ async function readEdges(page: Page): Promise<Reading> {
363384
left: {
364385
pageIcon: x(document.getElementById('page-icon')),
365386
viewIcon: x(document.getElementById('view-icon')),
387+
chartViewIcon: x(document.getElementById('chart-view-icon')),
366388
headerCheckbox: x(document.querySelector('thead [role="checkbox"]')),
367389
rowCheckboxes: rowBoxes.map((b) => x(b)),
368390
footerText: x(document.getElementById('footer-text')),
@@ -376,6 +398,10 @@ async function readEdges(page: Page): Promise<Reading> {
376398
footer: Math.round((main.right - r(document.getElementById('footer-text')!.parentElement).right) * 10) / 10,
377399
scrollBox: inRight(box),
378400
},
401+
barPaddingRight: {
402+
list: parseFloat(getComputedStyle(document.getElementById('viewbar')!).paddingRight),
403+
chart: parseFloat(getComputedStyle(document.getElementById('chartbar')!).paddingRight),
404+
},
379405
selection: { width: Math.round(r(lead).width * 10) / 10, left: x(lead) },
380406
rowNumbers: document.querySelectorAll('[data-slot="row-number"]').length,
381407
rowCheckboxOpacity: rowBoxes.map((b) => opacity(b)),
@@ -428,6 +454,7 @@ function expectOnEdge(r: Reading, edge: number, slack = 1): void {
428454
const named: Array<[string, number]> = [
429455
['page-bar icon', r.left.pageIcon],
430456
['view-bar icon', r.left.viewIcon],
457+
['chart view-bar icon', r.left.chartViewIcon],
431458
['select-all box', r.left.headerCheckbox],
432459
...r.left.rowCheckboxes.map((v, i): [string, number] => [`row ${i + 1} checkbox`, v]),
433460
['footer count', r.left.footerText],
@@ -462,6 +489,10 @@ test.describe('the list page draws one left edge (objectstack#35663)', () => {
462489
// on one line, 16 in, as the footer's padding does.
463490
expect(Math.abs(r.right.pageAction - r.right.viewCluster), `page action ${r.right.pageAction} vs view cluster ${r.right.viewCluster}`).toBeLessThanOrEqual(1);
464491
expect(Math.abs(r.right.pageAction - EDGE)).toBeLessThanOrEqual(1);
492+
// The chart view's view bar is the list's (objectstack#35729): its icon
493+
// is on the list's view icon (also in `expectOnEdge`), its right end the list bar's.
494+
expect(Math.abs(r.left.chartViewIcon - r.left.viewIcon), `chart view icon ${r.left.chartViewIcon} vs list view icon ${r.left.viewIcon}`).toBeLessThanOrEqual(1);
495+
expect(r.barPaddingRight.chart, 'the chart view bar ends where the list view bar does').toBe(r.barPaddingRight.list);
465496
});
466497
}
467498

@@ -494,13 +525,16 @@ test.describe('the list page draws one left edge (objectstack#35663)', () => {
494525
return {
495526
pageIcon: x(document.getElementById('page-icon')),
496527
viewIcon: x(document.getElementById('view-icon')),
528+
chartViewIcon: x(document.getElementById('chart-view-icon')),
497529
cardContent: cards.map((c) => x(c.firstElementChild)),
498530
footerText: x(document.getElementById('footer-text')),
499531
};
500532
});
501533
report(testInfo, 'phone', r);
502534
expect(r.cardContent.length).toBe(12);
503-
for (const at of [r.pageIcon, r.viewIcon, ...r.cardContent, r.footerText]) {
535+
// Below `sm` the chart view's view bar keeps the list bar's `px-2` (objectstack#35729).
536+
expect(Math.abs(r.chartViewIcon - r.viewIcon), `chart view icon ${r.chartViewIcon} vs list view icon ${r.viewIcon}`).toBeLessThanOrEqual(1);
537+
for (const at of [r.pageIcon, r.viewIcon, r.chartViewIcon, ...r.cardContent, r.footerText]) {
504538
expect(at).toBeGreaterThanOrEqual(12);
505539
}
506540
});

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ const CreateViewDialog = lazy(() =>
4747
import {
4848
usePreviewDrafts,
4949
} from '../preview/PreviewModeContext.js';
50-
import { isSetupAppSegment } from '../console/setupApp.js';
5150
import { IDENTITY_IMPORT_WRITE_MODES } from './identityImport.js';
5251
import { IdentityImportOptions, IdentityImportResultExtra, identityImportFields } from './IdentityImportPanels.js';
5352
import { ManagedUsersInviteLine } from './managedEnvironmentUsers.js';
@@ -198,10 +197,6 @@ function ObjectViewInner({ dataSource, objects, onEdit, externalRefreshKey }: Co
198197
// publishing `recordHref` uses (`documentHref`, objectui#12233).
199198
const routerRootHref = useHref('/');
200199
const { appName, objectName, viewId } = useParams();
201-
// objectui#12606 — inside the Setup app the list drops its `#` row
202-
// numbers (see the `ListView` below). Read off
203-
// the route's own `:appName`, the one signal the page header reads too.
204-
const inSetup = isSetupAppSegment(appName);
205200
const [searchParams, setSearchParamsNow] = useSearchParams();
206201
// The router's setter is a new function whenever the search changes, and
207202
// every list handler built on it (the URL state write-backs, the row
@@ -1044,7 +1039,6 @@ function ObjectViewInner({ dataSource, objects, onEdit, externalRefreshKey }: Co
10441039
// `renderListView` moved to `./objectViewListRenderer.tsx`.
10451040
const { renderListView } = useObjectViewListRenderer({
10461041
objectName,
1047-
inSetup,
10481042
t,
10491043
viewEmptyState,
10501044
localizeActionTexts,

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import { useMetadata } from '../providers/MetadataProvider.js';
2828
import type { DataSource } from '@object-ui/types';
2929
import { isSavedViewId } from '../utils/viewIdentity.js';
3030
import { warnSuppressedListNav } from '../utils/warnSuppressedListNav.js';
31-
import type { isSetupAppSegment } from '../console/setupApp.js';
3231
import type { useObjectActions } from '../hooks/useObjectActions.js';
3332
import { substituteFilterTokens } from './objectViewHelpers.js';
3433
import type { buildViewTabs } from './objectViewTabs.js';
@@ -74,7 +73,6 @@ export function withAddedListColumns(
7473

7574
export function useObjectViewListRenderer({
7675
objectName,
77-
inSetup,
7876
t,
7977
viewEmptyState,
8078
localizeActionTexts,
@@ -111,7 +109,6 @@ export function useObjectViewListRenderer({
111109
listViewActions,
112110
}: {
113111
objectName: string | undefined;
114-
inSetup: ReturnType<typeof isSetupAppSegment>;
115112
t: ReturnType<typeof useObjectTranslation>['t'];
116113
viewEmptyState: ReturnType<typeof useObjectLabel>['viewEmptyState'];
117114
localizeActionTexts: ReturnType<typeof useActionTextLocalizer>;
@@ -366,11 +363,17 @@ export function useObjectViewListRenderer({
366363
const chartConfig = viewDef.chart || {};
367364
// The way back to the other views is the view switcher
368365
// (objectstack#27594), which heads the chart in a bar of the
369-
// list's view bar's height (objectstack#27058, objectstack#35548).
366+
// list's view bar's height (objectstack#27058, objectstack#35548)
367+
// and the list's view bar's padding (`TOOLBAR_ROW` in
368+
// plugin-list's `listToolbarRow.ts`, objectstack#35729): from `sm`
369+
// up 10px on the left puts the switcher's 6px-padded icon on the
370+
// list page's 16px line (objectstack#35663), so switching between
371+
// the list and the chart does not move it; below `sm` both bars
372+
// keep `px-2`.
370373
const chartPage = (chartFace: ReactNode) => (
371374
<div className="h-full flex flex-col min-w-0">
372375
{hasPhoneTitle && (
373-
<div className="border-b px-2 py-1.5 sm:h-10 sm:px-4 sm:py-0 flex items-center min-w-0 bg-background">
376+
<div className="border-b px-2 py-1.5 sm:h-10 sm:pl-2.5 sm:pr-2 sm:py-0 flex items-center min-w-0 bg-background">
374377
<ViewBarLead store={leadStore} />
375378
</div>
376379
)}
@@ -1140,7 +1143,7 @@ export function useObjectViewListRenderer({
11401143
dataSource={ds}
11411144
/>
11421145
);
1143-
}, [inSetup, activeView, activeViewDeclaresColumns, activeViewIsSaved, objectDef, objectName, refreshKey, createRecord, urlFilters, initialUfSelections, handleUserFilterSelectionsChange, writeListUrlState, listPage, user?.id, pageOffersCreate, listAddRecordOpensCreate, listIdentityKey, listPrefs.ready, listPrefs.preference, listPrefs.patchView, managedUsers, managedUserMarker, recordOpen, openAsPage, rowOpensRecord, handleListRowsChange, hasPhoneTitle, leadStore, wideViewport, handleListPersonalizationChange, workspaceTimeZone, viewPanelFilters, offersRename, offersSave, offersReset, previewDrafts, previewDataSource, unpublishedObjects]);
1146+
}, [activeView, activeViewDeclaresColumns, activeViewIsSaved, objectDef, objectName, refreshKey, createRecord, urlFilters, initialUfSelections, handleUserFilterSelectionsChange, writeListUrlState, listPage, user?.id, pageOffersCreate, listAddRecordOpensCreate, listIdentityKey, listPrefs.ready, listPrefs.preference, listPrefs.patchView, managedUsers, managedUserMarker, recordOpen, openAsPage, rowOpensRecord, handleListRowsChange, hasPhoneTitle, leadStore, wideViewport, handleListPersonalizationChange, workspaceTimeZone, viewPanelFilters, offersRename, offersSave, offersReset, previewDrafts, previewDataSource, unpublishedObjects]);
11441147

11451148
return { renderListView };
11461149
}

0 commit comments

Comments
 (0)