fix: improve native print output for dashboards and record tables (#22272)
## Summary - Adds print-specific snapshots for dashboards so native browser print/PDF captures charts and front components instead of the app shell. - Adds record-table print snapshots for object index pages so printable tables are generated from visible rows and native print avoids virtualized blank pages. - Preserves rendered chart layers by rasterizing canvas/SVG content for print. ## AI-generated disclosure This pull request was AI-generated by Hermes Agent on behalf of Vittorio Alfieri. The changes were reviewed and tested locally before submission. ## Screenshots ### Dashboard print **Before**  **After**  ### Table records print **Before**  **After**  ## Test plan - [x] `yarn nx typecheck twenty-front` - [x] `yarn nx build twenty-front` - [x] Generated dashboard PDFs from the preview build and rasterized pages to PNG for visual verification. - [x] Generated Tasks/table-record PDFs from the preview build and verified the final page contains table content instead of blank pages. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/twentyhq/twenty/pull/22272?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. --> --------- Co-authored-by: Félix Malfait <felix@twenty.com> Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
This commit is contained in:
@@ -86,6 +86,34 @@ const StyledGridContainer = styled.div`
|
||||
.react-grid-item:hover .widget-card-resize-handle {
|
||||
display: block !important;
|
||||
}
|
||||
|
||||
@media print {
|
||||
min-height: auto;
|
||||
padding: 0;
|
||||
user-select: auto;
|
||||
|
||||
.react-grid-layout {
|
||||
height: auto !important;
|
||||
}
|
||||
|
||||
// Flow the absolutely-positioned grid items into the page, but keep the
|
||||
// pixel width and height react-grid-layout sets inline: the charts are sized
|
||||
// by a resize observer (Nivo SVG and a custom canvas bar chart), so changing
|
||||
// their box would re-measure mid-print and render them blank.
|
||||
.react-grid-item {
|
||||
break-inside: avoid;
|
||||
margin-bottom: ${themeCssVariables.spacing[4]};
|
||||
page-break-inside: avoid;
|
||||
position: static !important;
|
||||
transform: none !important;
|
||||
}
|
||||
|
||||
.react-grid-placeholder,
|
||||
.react-resizable-handle,
|
||||
.widget-card-resize-handle {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
type ExtendedResponsiveProps = ResponsiveProps & {
|
||||
|
||||
@@ -36,17 +36,41 @@ const StyledContainer = styled.div<{ hasPinnedTab: boolean }>`
|
||||
grid-template-rows: minmax(0, 1fr);
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
|
||||
@media print {
|
||||
display: block;
|
||||
height: auto;
|
||||
width: 100%;
|
||||
}
|
||||
`;
|
||||
|
||||
const StyledTabsAndDashboardContainer = styled.div`
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
|
||||
@media print {
|
||||
display: block;
|
||||
overflow: visible;
|
||||
|
||||
.page-layout-tab-list-print-hidden {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const StyledScrollWrapperContainer = styled.div`
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
|
||||
@media print {
|
||||
min-height: auto;
|
||||
|
||||
.page-layout-scroll-wrapper {
|
||||
height: auto;
|
||||
overflow: visible;
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const PageLayoutTabsRenderer = () => {
|
||||
@@ -184,6 +208,7 @@ export const PageLayoutTabsRenderer = () => {
|
||||
/>
|
||||
{(sortedActiveTabs.length > 1 || isPageLayoutInEditMode) && (
|
||||
<PageLayoutTabList
|
||||
className="page-layout-tab-list-print-hidden"
|
||||
tabs={sortedActiveTabs}
|
||||
behaveAsLinks={!isInSidePanel && !isPageLayoutInEditMode}
|
||||
isInSidePanel={isInSidePanel}
|
||||
@@ -206,6 +231,7 @@ export const PageLayoutTabsRenderer = () => {
|
||||
|
||||
<StyledScrollWrapperContainer>
|
||||
<ScrollWrapper
|
||||
className="page-layout-scroll-wrapper"
|
||||
componentInstanceId={getScrollWrapperInstanceIdFromPageLayoutId(
|
||||
currentPageLayout.id,
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user