Repository navigation
Improve the PDF Filename #13216
Copy link
Copy link
Closed
Labels
P2Low priorityLow priorityTeam SIssues for Squad 1Issues for Squad 1Type: EnhancementImprovement of an existing featureImprovement of an existing feature
Description
Feature Description
The Design doc states the file name as:
A PDF file downloads automatically with a filename like Site Kit Dashboard - example.com - Mar 1-7 2026.pdf
Current file name:
site-kit-pdfgenerationbugbash-instawp-co-last-28-days-2026-07-29.pdf
Site Kit Dashboard isn't there and the domain should be proper without dashes in the middle.
Date doesn't match the expected format.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- The exported PDF downloads with a filename in the form
Site Kit Dashboard - example.com - Mar 1 – 7, 2026.pdf. - The site segment shows the site's domain, matching the address shown in the report header.
- The date segment covers the same reporting period as the report header, written in the compact range format below rather than the header's two full dates.
- A reporting period inside a single month shows the month and year once, for example
Mar 1 – 7, 2026. - A reporting period spanning two months or two years shows both in full, for example
Dec 28, 2025 – Jan 3, 2026. - The date segment follows the user's locale.
- The filename no longer carries the date the report was generated.
- Characters that filesystems reject are removed from the filename, so the download succeeds on Windows, macOS and Linux.
Implementation Brief
Files to modify:
- Update file
assets/js/components/pdf-export/pdf-utils.ts:- Change
getPDFFilenameto take the reference site URL and the report's{ startDate, endDate }, returning<prefix> - <host> - <range>.pdfwith the prefixSite Kit Dashboardwrapped in__(). - Move
getSiteHosthere fromPDFHeader.tsxand export it. - Format the range with
Intl.DateTimeFormat( getLocale(), { month: 'short', day: 'numeric', year: 'numeric' } ).formatRange()overstringToDate, guarded byisValidDateStringasformatDateStringdoes. Omit the segment and its separator when either date is invalid, mirroring the header's dangling-separator guard. - Strip the characters filesystems reject (
\ / : * ? " < > |and control characters) plus trailing dots and spaces, and collapse whitespace runs. Keep the existingreportfallback for when no host resolves. - Remove
slugifyandgetISODatewith the generation date stamp.
- Change
- Update file
assets/js/components/pdf-export/shared-react-pdf-components/PDFHeader.tsx: importgetSiteHostfrompdf-utilsand delete the local copy. - Update file
assets/js/components/pdf-export/PDFExportOrchestrator.tsx: passreferenceSiteURLand thedatesalready selected for the header intogetPDFFilename, and remove thegetDateRangeselector with thereferenceNameandresolvedDateRangelocals it fed.
Test Coverage
- Create file
assets/js/components/pdf-export/pdf-utils.test.ts: assert the composed filename for a same-month, a cross-month and a cross-year reporting period. - Same file: assert the host comes from the reference URL with the scheme and path removed, and that an unparseable URL falls back to the
reportsegment. - Same file: assert an invalid start or end date drops the range segment without leaving a dangling separator.
- Same file: assert reserved characters and trailing dots and spaces are stripped from the composed name.
- Update file
assets/js/components/pdf-export/PDFExportOrchestrator.test.tsx: asserttriggerDownloadreceives a filename in the new format built from the export's reporting period. - No Storybook or VRT entries: the change is a filename string and the header keeps its rendered output.
QA Brief
- On the Site Kit dashboard, click Download PDF report in the header, then Download report in the panel. Verify the downloaded file is named
Site Kit Dashboard - <your-domain> - <date range>.pdf, e.g.Site Kit Dashboard - example.com - Sep 4 – Oct 1, 2026.pdf:- The domain matches the site address shown in the PDF header, with no
https://, path or dashes replacing dots. - The date range covers the same period as the PDF header, in the compact form (month and year shown once for a single-month range, e.g.
Mar 1 – 7, 2026; both in full when it spans months or years). - The filename no longer ends with the generation date.
- The domain matches the site address shown in the PDF header, with no
- Change the dashboard date range (e.g. to the last 7 days) and export again; verify the filename's range follows.
- Switch the site language (Settings → General → Site Language, e.g. Deutsch) and export again; verify the date range in the filename is in that language, e.g.
4. Sept. – 1. Okt. 2026. - Verify the file downloads and opens normally on Windows, macOS and Linux.
Changelog entry
- Improve the exported PDF filename to name the site and the reporting period.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P2Low priorityLow priorityTeam SIssues for Squad 1Issues for Squad 1Type: EnhancementImprovement of an existing featureImprovement of an existing feature
Activity
zutigrm commentedon Aug 20, 2026
Thanks @benbowler , just one thing to clarify in AC:
This won't be a literal match. The header joins two full dates with " - "
site-kit-wp/assets/js/components/pdf-export/shared-react-pdf-components/PDFHeader.tsx
Lines 152 to 157 in 4944374
giving Mar 1, 2026 - Mar 7, 2026, while the filename gives Mar 1 – 7, 2026. Same reporting period, different formatting. For the different months suggested format in AC is correct, but not for the same month. Worth rewording this one, or aligning the formats.
benbowler commentedon Aug 20, 2026
Good catch, reworded that bullet so it no longer implies a literal match: it now says the date segment covers the same reporting period as the header but in the compact range format (
Mar 1 – 7, 2026) rather than the header's two full dates. The two format bullets below it already spell out the same-month and cross-month cases.5 remaining items
kelvinballoo commentedon Oct 9, 2026
QA Update ✅
Tested a couple of timeframes and it's generated fine with the file name as expected.
Details
Deutsche language will have the dates recorded in that language.
Details
I was not able to verify on Linux as I don't have a machine. That said, Claude helped to generate and verify the downloaded filename Site Kit Dashboard - oi.ie - Jul 11 – Oct 8, 2026.pdf contains no characters Linux rejects (only / and NUL are disallowed).
Windows - Mohit helped to verify and it's fine.
Details
Mac (All my above tests were on Mac)
View dashboard downloads are also as expected.
Details