Skip to content

Commit e47a798

Browse files
committed
fix(app-shell): the chart view's view bar starts its icon on the list page's 16px edge
The chart view's own copy of the view bar kept sm:px-4 after the list view's bar moved to sm:pl-2.5 sm:pr-2, so at sm and up its view icon sat at 22 while the list's sat at 16. It now carries the list bar's padding. Below sm both keep px-2. The list renderer's inSetup input, read only in a memo dependency list since the Setup row-number line went, is removed end to end. The list left-edge geometry spec gains a chart view bar, read from the renderer's source, pinned to the list's view icon at 1280 and 375. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6Cb8qTxAVaE2QKwquQU
1 parent 65fddc8 commit e47a798

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
)}
@@ -1142,7 +1145,7 @@ export function useObjectViewListRenderer({
11421145
dataSource={ds}
11431146
/>
11441147
);
1145-
}, [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]);
1148+
}, [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]);
11461149

11471150
return { renderListView };
11481151
}

0 commit comments

Comments
 (0)