fix(page-layout): respect tab layoutMode on standalone pages (#20856)
Standalone-page tabs with `layoutMode: CANVAS` were silently rendering as GRID (border, padding, scroll). Now they render full-bleed, matching the CANVAS contract elsewhere. Three layered fixes: - `getTabLayoutMode`: respect `tab.layoutMode` for `STANDALONE_PAGE` (was hardcoded to GRID for any non-`RECORD_PAGE`) - `getWidgetCardVariant`: CANVAS now wins regardless of page type — refactored to early-return + exhaustive switch on `pageLayoutType` - `FrontComponentWidgetRenderer`: removed hardcoded `overflow: auto` (workflow/tasks/timeline widgets don't have it either) New `getTabLayoutMode.test.ts`. Variant tests refactored to declarative + parameterized. QA: <img width="3024" height="1654" alt="CleanShot 2026-05-22 at 20 46 50@2x" src="https://github.com/user-attachments/assets/cc61d459-6bc6-48de-ac79-d63a2ccd8957" /> https://github.com/user-attachments/assets/a3374e18-ad1b-4888-ab2b-d07730edccac
This commit is contained in:
+46
@@ -0,0 +1,46 @@
|
||||
import { type PageLayoutTab } from '@/page-layout/types/PageLayoutTab';
|
||||
import { getTabLayoutMode } from '@/page-layout/utils/getTabLayoutMode';
|
||||
import {
|
||||
PageLayoutTabLayoutMode,
|
||||
PageLayoutType,
|
||||
} from '~/generated-metadata/graphql';
|
||||
|
||||
const buildTab = (layoutMode: PageLayoutTabLayoutMode) =>
|
||||
({ layoutMode }) as unknown as PageLayoutTab;
|
||||
|
||||
describe('getTabLayoutMode', () => {
|
||||
describe('page types that respect tab.layoutMode', () => {
|
||||
it.each([PageLayoutType.RECORD_PAGE, PageLayoutType.STANDALONE_PAGE])(
|
||||
"returns the tab's layoutMode for %s",
|
||||
(pageLayoutType) => {
|
||||
const tab = buildTab(PageLayoutTabLayoutMode.CANVAS);
|
||||
|
||||
expect(getTabLayoutMode({ tab, pageLayoutType })).toBe(
|
||||
PageLayoutTabLayoutMode.CANVAS,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
it.each([PageLayoutType.RECORD_PAGE, PageLayoutType.STANDALONE_PAGE])(
|
||||
'throws when tab is undefined for %s',
|
||||
(pageLayoutType) => {
|
||||
expect(() =>
|
||||
getTabLayoutMode({ tab: undefined, pageLayoutType }),
|
||||
).toThrow('Tab layout mode is not defined');
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
describe('page types that ignore tab.layoutMode and default to GRID', () => {
|
||||
it.each([PageLayoutType.DASHBOARD, PageLayoutType.RECORD_INDEX])(
|
||||
'returns GRID for %s regardless of tab.layoutMode',
|
||||
(pageLayoutType) => {
|
||||
const tab = buildTab(PageLayoutTabLayoutMode.CANVAS);
|
||||
|
||||
expect(getTabLayoutMode({ tab, pageLayoutType })).toBe(
|
||||
PageLayoutTabLayoutMode.GRID,
|
||||
);
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -14,7 +14,10 @@ export const getTabLayoutMode = ({
|
||||
tab,
|
||||
pageLayoutType,
|
||||
}: GetTabLayoutModeParams): PageLayoutTabLayoutMode => {
|
||||
if (pageLayoutType === PageLayoutType.RECORD_PAGE) {
|
||||
if (
|
||||
pageLayoutType === PageLayoutType.RECORD_PAGE ||
|
||||
pageLayoutType === PageLayoutType.STANDALONE_PAGE
|
||||
) {
|
||||
assertPageLayoutTabHasDefinedLayoutModeOrThrow(tab);
|
||||
|
||||
return tab.layoutMode;
|
||||
|
||||
Reference in New Issue
Block a user