Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[data grid] Cannot print without footer #14861

Open
timonla opened this issue Oct 7, 2024 · 2 comments · May be fixed by #14863
Open

[data grid] Cannot print without footer #14861

timonla opened this issue Oct 7, 2024 · 2 comments · May be fixed by #14863
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! feature: Export

Comments

@timonla
Copy link

timonla commented Oct 7, 2024

Steps to reproduce

Link to live example: https://stackblitz.com/edit/github-kbnsbh?file=src%2Fdemo.tsx

Steps:

  1. Use the DataGrid component with property hideFooter={true}
  2. Add a toolbar containing GridToolbarExport component without printOptions={{ hideFooter: true}}
  3. Print the data grid

Current behavior

Print window does not open, error about missing footer element instead

Expected behavior

Print window opens

Context

When the print window is opened, properties are assigned to a missing footer element. I guess there should be a check if the footer actually exists before the following lines 189-191:

if (!normalizeOptions.hideFooter) {
// the footer is always being placed at the bottom of the page as if all rows are exported
// so if getRowsToExport is being used to only export a subset of rows then we need to
// adjust the footer position to be correctly placed at the bottom of the grid
const gridFooterElement: HTMLElement | null = gridClone.querySelector(
`.${gridClasses.footerContainer}`,
)!;
gridFooterElement.style.position = 'absolute';
gridFooterElement.style.width = '100%';
gridFooterElement.style.top = `${computedTotalHeight - gridFooterElementHeight}px`;
}

Compare to where the hideFooter option is applied and the footer is only removed if it exists:

if (normalizeOptions.hideFooter) {
gridClone.querySelector(`.${gridClasses.footerContainer}`)?.remove();
gridFooterElementHeight = 0;
}

Your environment

Search keywords: DataGrid Print

@timonla timonla added bug 🐛 Something doesn't work status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Oct 7, 2024
@github-actions github-actions bot added the component: data grid This is the name of the generic UI component, not the React module! label Oct 7, 2024
@timonla
Copy link
Author

timonla commented Oct 7, 2024

A workaround is of course to enable the footer hiding for each toolbar that is used in a data grid that does not have a footer but I feel like that should not be required.

@k-rajat19 k-rajat19 linked a pull request Oct 7, 2024 that will close this issue
1 task
@k-rajat19
Copy link
Contributor

I have opened a PR for that, it should actually check first for the hideFooter root prop if it is not there (false by default) then it should consider what is passed in printOptions.

@michelengelen michelengelen changed the title DataGrid cannot print without footer [data grid] Cannot print without footer Oct 8, 2024
@michelengelen michelengelen added feature: Export and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! feature: Export
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants