Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .changeset/35729-chart-view-bar-left-edge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
'@object-ui/app-shell': patch
---

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

Clause-②: no
Metadata-protocol: none

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.

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.
40 changes: 37 additions & 3 deletions ui/e2e/list-left-edge-35663.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ import { uiRoot } from '../scripts/ui-root.mjs';
* the switcher's and footer's contents are short literals. Fonts are
* Chromium's fallbacks: the assertions are edges and widths of boxes, not of
* glyphs.
*
* ## The chart view's view bar (objectstack#35729)
*
* A chart view draws its own copy of the view bar (`chartPage` in
* `objectViewListRenderer.tsx`), which kept `sm:px-4` after #35663 and so put
* the view icon at 22. Its class is read out of that file at run time and a
* second bar with that class, holding the same switcher, sits under the list's
* view bar: at 1280 its icon starts on the list's 16 and its right padding is
* the list bar's; at 375 it is no closer than 12 to the left edge.
*/

const REPO_ROOT = uiRoot();
Expand Down Expand Up @@ -76,6 +85,11 @@ const SWITCHER_CLASS = pick(
/data-testid="list-view-switcher"[\s\S]*?className=\{cn\(\s*(?:\/\/[^\n]*\n\s*)*'([^']+)'/,
'the switcher trigger class',
);
const CHART_BAR_CLASS = pick(
'packages/app-shell/src/views/objectViewListRenderer.tsx',
/const chartPage = [\s\S]*?hasPhoneTitle && \(\s*<div className="([^"]+)"/,
'the chart view bar class',
);
const FOOTER_CLASS = pick(
'packages/plugin-list/src/ListView.tsx',
/className="([^"]+)"\s*data-testid="record-count-bar"/,
Expand All @@ -100,6 +114,7 @@ interface Case {
sidebar: number;
columns: string[];
switcherClass: string;
chartBarClass: string;
footerClass: string;
}

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

/** Mount the case, style it, and wait until the table's geometry holds still. */
async function mount(page: Page, c: Omit<Case, 'switcherClass' | 'footerClass'>): Promise<void> {
async function mount(page: Page, c: Omit<Case, 'switcherClass' | 'chartBarClass' | 'footerClass'>): Promise<void> {
await page.setViewportSize({ width: c.viewport, height: 800 });
await page.setContent('<!doctype html><html><head><style>html,body{margin:0}</style></head><body><div id="root"></div></body></html>');
await page.evaluate((value) => {
(window as unknown as { __case: Case }).__case = value;
}, { ...c, switcherClass: SWITCHER_CLASS, footerClass: FOOTER_CLASS });
}, { ...c, switcherClass: SWITCHER_CLASS, chartBarClass: CHART_BAR_CLASS, footerClass: FOOTER_CLASS });
await page.addScriptTag({ content: bundle, type: 'module' });
// Below 768 the grid draws cards, not a table.
await page.locator('tbody [role="checkbox"], [data-testid="grid-mobile-card"]').first().waitFor({ state: 'attached', timeout: 30_000 });
Expand All @@ -309,6 +326,8 @@ interface Reading {
left: {
pageIcon: number;
viewIcon: number;
/** The chart view's view bar (objectstack#35729). */
chartViewIcon: number;
headerCheckbox: number;
rowCheckboxes: number[];
footerText: number;
Expand All @@ -317,6 +336,8 @@ interface Reading {
};
/** Right edges, from the main area's right (distance in): the page bar's button box, the view bar's last label. */
right: { pageAction: number; viewCluster: number; footer: number; scrollBox: number };
/** The right padding of the list's view bar and of the chart view's (objectstack#35729). */
barPaddingRight: { list: number; chart: number };
/** The selection column's header cell: width and drawn left, from the main area. */
selection: { width: number; left: number };
rowNumbers: number;
Expand Down Expand Up @@ -363,6 +384,7 @@ async function readEdges(page: Page): Promise<Reading> {
left: {
pageIcon: x(document.getElementById('page-icon')),
viewIcon: x(document.getElementById('view-icon')),
chartViewIcon: x(document.getElementById('chart-view-icon')),
headerCheckbox: x(document.querySelector('thead [role="checkbox"]')),
rowCheckboxes: rowBoxes.map((b) => x(b)),
footerText: x(document.getElementById('footer-text')),
Expand All @@ -376,6 +398,10 @@ async function readEdges(page: Page): Promise<Reading> {
footer: Math.round((main.right - r(document.getElementById('footer-text')!.parentElement).right) * 10) / 10,
scrollBox: inRight(box),
},
barPaddingRight: {
list: parseFloat(getComputedStyle(document.getElementById('viewbar')!).paddingRight),
chart: parseFloat(getComputedStyle(document.getElementById('chartbar')!).paddingRight),
},
selection: { width: Math.round(r(lead).width * 10) / 10, left: x(lead) },
rowNumbers: document.querySelectorAll('[data-slot="row-number"]').length,
rowCheckboxOpacity: rowBoxes.map((b) => opacity(b)),
Expand Down Expand Up @@ -428,6 +454,7 @@ function expectOnEdge(r: Reading, edge: number, slack = 1): void {
const named: Array<[string, number]> = [
['page-bar icon', r.left.pageIcon],
['view-bar icon', r.left.viewIcon],
['chart view-bar icon', r.left.chartViewIcon],
['select-all box', r.left.headerCheckbox],
...r.left.rowCheckboxes.map((v, i): [string, number] => [`row ${i + 1} checkbox`, v]),
['footer count', r.left.footerText],
Expand Down Expand Up @@ -462,6 +489,10 @@ test.describe('the list page draws one left edge (objectstack#35663)', () => {
// on one line, 16 in, as the footer's padding does.
expect(Math.abs(r.right.pageAction - r.right.viewCluster), `page action ${r.right.pageAction} vs view cluster ${r.right.viewCluster}`).toBeLessThanOrEqual(1);
expect(Math.abs(r.right.pageAction - EDGE)).toBeLessThanOrEqual(1);
// The chart view's view bar is the list's (objectstack#35729): its icon
// is on the list's view icon (also in `expectOnEdge`), its right end the list bar's.
expect(Math.abs(r.left.chartViewIcon - r.left.viewIcon), `chart view icon ${r.left.chartViewIcon} vs list view icon ${r.left.viewIcon}`).toBeLessThanOrEqual(1);
expect(r.barPaddingRight.chart, 'the chart view bar ends where the list view bar does').toBe(r.barPaddingRight.list);
});
}

Expand Down Expand Up @@ -494,13 +525,16 @@ test.describe('the list page draws one left edge (objectstack#35663)', () => {
return {
pageIcon: x(document.getElementById('page-icon')),
viewIcon: x(document.getElementById('view-icon')),
chartViewIcon: x(document.getElementById('chart-view-icon')),
cardContent: cards.map((c) => x(c.firstElementChild)),
footerText: x(document.getElementById('footer-text')),
};
});
report(testInfo, 'phone', r);
expect(r.cardContent.length).toBe(12);
for (const at of [r.pageIcon, r.viewIcon, ...r.cardContent, r.footerText]) {
// Below `sm` the chart view's view bar keeps the list bar's `px-2` (objectstack#35729).
expect(Math.abs(r.chartViewIcon - r.viewIcon), `chart view icon ${r.chartViewIcon} vs list view icon ${r.viewIcon}`).toBeLessThanOrEqual(1);
for (const at of [r.pageIcon, r.viewIcon, r.chartViewIcon, ...r.cardContent, r.footerText]) {
expect(at).toBeGreaterThanOrEqual(12);
}
});
Expand Down
6 changes: 0 additions & 6 deletions ui/packages/app-shell/src/views/ObjectView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ const CreateViewDialog = lazy(() =>
import {
usePreviewDrafts,
} from '../preview/PreviewModeContext.js';
import { isSetupAppSegment } from '../console/setupApp.js';
import { IDENTITY_IMPORT_WRITE_MODES } from './identityImport.js';
import { IdentityImportOptions, IdentityImportResultExtra, identityImportFields } from './IdentityImportPanels.js';
import { ManagedUsersInviteLine } from './managedEnvironmentUsers.js';
Expand Down Expand Up @@ -198,10 +197,6 @@ function ObjectViewInner({ dataSource, objects, onEdit, externalRefreshKey }: Co
// publishing `recordHref` uses (`documentHref`, objectui#12233).
const routerRootHref = useHref('/');
const { appName, objectName, viewId } = useParams();
// objectui#12606 — inside the Setup app the list drops its `#` row
// numbers (see the `ListView` below). Read off
// the route's own `:appName`, the one signal the page header reads too.
const inSetup = isSetupAppSegment(appName);
const [searchParams, setSearchParamsNow] = useSearchParams();
// The router's setter is a new function whenever the search changes, and
// every list handler built on it (the URL state write-backs, the row
Expand Down Expand Up @@ -1044,7 +1039,6 @@ function ObjectViewInner({ dataSource, objects, onEdit, externalRefreshKey }: Co
// `renderListView` moved to `./objectViewListRenderer.tsx`.
const { renderListView } = useObjectViewListRenderer({
objectName,
inSetup,
t,
viewEmptyState,
localizeActionTexts,
Expand Down
15 changes: 9 additions & 6 deletions ui/packages/app-shell/src/views/objectViewListRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import { useMetadata } from '../providers/MetadataProvider.js';
import type { DataSource } from '@object-ui/types';
import { isSavedViewId } from '../utils/viewIdentity.js';
import { warnSuppressedListNav } from '../utils/warnSuppressedListNav.js';
import type { isSetupAppSegment } from '../console/setupApp.js';
import type { useObjectActions } from '../hooks/useObjectActions.js';
import { substituteFilterTokens } from './objectViewHelpers.js';
import type { buildViewTabs } from './objectViewTabs.js';
Expand Down Expand Up @@ -74,7 +73,6 @@ export function withAddedListColumns(

export function useObjectViewListRenderer({
objectName,
inSetup,
t,
viewEmptyState,
localizeActionTexts,
Expand Down Expand Up @@ -111,7 +109,6 @@ export function useObjectViewListRenderer({
listViewActions,
}: {
objectName: string | undefined;
inSetup: ReturnType<typeof isSetupAppSegment>;
t: ReturnType<typeof useObjectTranslation>['t'];
viewEmptyState: ReturnType<typeof useObjectLabel>['viewEmptyState'];
localizeActionTexts: ReturnType<typeof useActionTextLocalizer>;
Expand Down Expand Up @@ -366,11 +363,17 @@ export function useObjectViewListRenderer({
const chartConfig = viewDef.chart || {};
// The way back to the other views is the view switcher
// (objectstack#27594), which heads the chart in a bar of the
// list's view bar's height (objectstack#27058, objectstack#35548).
// list's view bar's height (objectstack#27058, objectstack#35548)
// and the list's view bar's padding (`TOOLBAR_ROW` in
// plugin-list's `listToolbarRow.ts`, objectstack#35729): from `sm`
// up 10px on the left puts the switcher's 6px-padded icon on the
// list page's 16px line (objectstack#35663), so switching between
// the list and the chart does not move it; below `sm` both bars
// keep `px-2`.
const chartPage = (chartFace: ReactNode) => (
<div className="h-full flex flex-col min-w-0">
{hasPhoneTitle && (
<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">
<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">
<ViewBarLead store={leadStore} />
</div>
)}
Expand Down Expand Up @@ -1142,7 +1145,7 @@ export function useObjectViewListRenderer({
dataSource={ds}
/>
);
}, [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]);
}, [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]);

return { renderListView };
}
Expand Down
Loading