diff --git a/.changeset/35729-chart-view-bar-left-edge.md b/.changeset/35729-chart-view-bar-left-edge.md new file mode 100644 index 00000000000..e4aae2397e5 --- /dev/null +++ b/.changeset/35729-chart-view-bar-left-edge.md @@ -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. diff --git a/ui/e2e/list-left-edge-35663.spec.ts b/ui/e2e/list-left-edge-35663.spec.ts index fa5de9059f4..78f0d759978 100644 --- a/ui/e2e/list-left-edge-35663.spec.ts +++ b/ui/e2e/list-left-edge-35663.spec.ts @@ -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(); @@ -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*
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, @@ -277,12 +294,12 @@ async function styleUntilStable(page: Page, compiled: Set): Promise): Promise { +async function mount(page: Page, c: Omit): Promise { await page.setViewportSize({ width: c.viewport, height: 800 }); await page.setContent('
'); 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 }); @@ -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; @@ -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; @@ -363,6 +384,7 @@ async function readEdges(page: Page): Promise { 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')), @@ -376,6 +398,10 @@ async function readEdges(page: Page): Promise { 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)), @@ -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], @@ -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); }); } @@ -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); } }); diff --git a/ui/packages/app-shell/src/views/ObjectView.tsx b/ui/packages/app-shell/src/views/ObjectView.tsx index 81372b72973..4c24e16db0a 100644 --- a/ui/packages/app-shell/src/views/ObjectView.tsx +++ b/ui/packages/app-shell/src/views/ObjectView.tsx @@ -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'; @@ -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 @@ -1044,7 +1039,6 @@ function ObjectViewInner({ dataSource, objects, onEdit, externalRefreshKey }: Co // `renderListView` moved to `./objectViewListRenderer.tsx`. const { renderListView } = useObjectViewListRenderer({ objectName, - inSetup, t, viewEmptyState, localizeActionTexts, diff --git a/ui/packages/app-shell/src/views/objectViewListRenderer.tsx b/ui/packages/app-shell/src/views/objectViewListRenderer.tsx index 45ba77619a5..7747ceb178b 100644 --- a/ui/packages/app-shell/src/views/objectViewListRenderer.tsx +++ b/ui/packages/app-shell/src/views/objectViewListRenderer.tsx @@ -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'; @@ -74,7 +73,6 @@ export function withAddedListColumns( export function useObjectViewListRenderer({ objectName, - inSetup, t, viewEmptyState, localizeActionTexts, @@ -111,7 +109,6 @@ export function useObjectViewListRenderer({ listViewActions, }: { objectName: string | undefined; - inSetup: ReturnType; t: ReturnType['t']; viewEmptyState: ReturnType['viewEmptyState']; localizeActionTexts: ReturnType; @@ -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) => (
{hasPhoneTitle && ( -
+
)} @@ -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 }; }