Skip to content

Open the export dialog with the flatten option matching the report on screen - #25894

Open
AltamashShaikh wants to merge 4 commits into
6.x-devfrom
DEV-20653
Open

AltamashShaikh wants to merge 4 commits into
6.x-devfrom
DEV-20653

Conversation

@AltamashShaikh

Copy link
Copy Markdown
Contributor

Description

Bug: When you open the Export dialog on a report that can be flattened but is shown hierarchically (for example Behaviour > Pages), "Flatten report" is already ticked. If you export without noticing, the file is flat and doesn't match the report on screen.

Root cause: plugins/CoreHome/vue/src/ReportExport/ReportExport.ts opened the popover with initialOptionFlat = canExportFlat. Flat was pre-selected whenever flat export was available, whatever the report's current state. This was a deliberate default from #24045 (TSV + flat on open).

Fix: The popover now starts flat only when the report is currently flattened (canExportFlat && isDataTableFlat, using the param.flat value the directive already reads). Nothing else changes:

  • A flattened report still opens with "Flatten report" ticked.
  • A hierarchical report opens unflattened. Switching it to JSON/XML opens with neither "flat" nor "expanded" ticked, which matches the collapsed subtables on screen. Users can still tick either option, and their choice is remembered across format switches as before.
  • Row limit and "show dimensions" were already taken from the report, and are unchanged.

Note for product: this reverses the "flat by default" choice from #24045, as the bug report asks.

Tests:

  • New Vitest cases in ReportExport.spec.ts: a hierarchical report with subtables opens the popover with initialOptionFlat=false (this failed before the fix), and a flat report opens it with initialOptionFlat=true.
  • plugins/CoreHome/tests/UI/ReportExportPopover_spec.js now expects the new default. The cases with no current subtables now tick "flat" themselves to prove it is still available. All 6 tests pass locally.
  • ReportExporting_Referrers.getWebsites_exported.* expected files were updated: the Websites report is shown hierarchical, so its default exports are now unflattened (CSV/TSV) and without expanded subtables (XML/JSON). These are the new outputs from a local UI test run.
  • ViewDataTable_export_options.png (Git LFS) is expected to change, because "Flatten report" is now unticked for the hierarchical Keywords report. It could not be regenerated locally and needs updating from the CI artifacts.
  • Manual check in headless Chrome on the UI test fixture: Behaviour > Pages, open Export. Before the fix, TSV was selected with "Flatten report" ticked and flat=1 in the link. After the fix, TSV is selected, flat is unticked and there is no flat=1. The same report forced to flat still opens with flat ticked. No page errors.

QA

Checked in a browser on a test install, following the bug's steps before and after the fix.

Steps:

  1. Set up UITestFixture on the test install (./console tests:setup-fixture UITestFixture) and logged in as the fixture super user in headless Chrome. 2. Opened Behaviour > Pages for 2012-08-09 (report shown hierarchical: param.flat unset, 5 rows with subtables). 3. Opened the Export dialog. Before the fix: TSV selected, 'Flatten report' ticked, export link contains flat=1 (bug). 4. Applied the patch to the test install, cleared merged JS assets, repeated steps 2-3. After the fix: TSV selected, 'Flatten report' unticked, no flat=1 in the export link. 5. Closed the dialog, set the report to flat (param.flat=1) and reopened Export: 'Flatten report' ticked and flat=1, as before. 6. No JavaScript page errors in either run; reverted the test install afterwards.

Before the fix: Behaviour > Pages shown hierarchical (unflattened) on the test fixture

before-1.png

Before the fix: the Export dialog opens with 'Flatten report' ticked although the report on screen is not flat

before-2.png

After the fix: the same hierarchical Pages report

after-1.png

After the fix: the Export dialog opens with 'Flatten report' unticked, matching the report on screen

after-2.png

Checklist

  • [✖] I have understood, reviewed, and tested all AI outputs before use
  • [✔] All AI instructions respect security, IP, and privacy rules

Review

🤖 Generated with Claude Code

…creen

The export popover always opened with "flat" ticked when flat export was
available, so exporting an unflattened (hierarchical) report produced a
flat file that did not match what was shown. It now starts flat only when
the report is currently flattened.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AltamashShaikh AltamashShaikh added this to the 6.1.0 milestone Dec 1, 2026
# Conflicts:
#	plugins/CoreHome/vue/dist/CoreHome.umd.min.js
@AltamashShaikh

Copy link
Copy Markdown
Contributor Author

Auto-fix agent: merged 6.x-dev into this PR (conflicts resolved in plugins/CoreHome/vue/dist/CoreHome.umd.min.js).

Only the generated bundle plugins/CoreHome/vue/dist/CoreHome.umd.min.js conflicted: 6.x-dev rebuilt it for the themed notification close icon (#25888), and this PR rebuilt it for the ReportExport flat-option fix.
Resolved by rebuilding CoreHome from the merged Vue sources (vite-runner). The rebuilt bundle differs from 6.x-dev's only by the PR's change (initialOptionFlat:u -> u&&l), so both sides are kept and the fix is not widened.
Vitest ReportExport.spec.ts 5/5, UI ReportExportPopover 6/6 and ReportExporting 13/13 pass; the PR changes no PHP files, so PHPCS has nothing to check.

@AltamashShaikh

Copy link
Copy Markdown
Contributor Author

Auto-fix agent: the failing checks (All required tests passed) need a developer; the agent will not push to this PR again.

Only the UI-core job failed (the 'All required tests passed' gate reports UI-core: failure; PHP, plugin UI, JS and client jobs passed). The UI-core log was not saved and GitHub is not reachable here, so the failing test was found by running both core specs that open the export popover, on 6.x-dev and with the PR.
ReportExporting passes 13/13 with the PR. ViewDataTableTest: 25 of 26 screenshots are byte-identical between 6.x-dev and the PR; only ViewDataTableTest_export_options differs. On 6.x-dev 'Flatten report' is ticked and 'Include dimensions separately' shows; with the PR, flatten is unticked and that option is hidden (the Keywords report is hierarchical at that step). That is this PR's intended change, and the PR does not update that expected screenshot, so UI-core fails on it.
Nothing changed: the screenshot must come from the CI artifact (local rendering is not byte-identical to CI, and git-lfs is not installed).

Needs a developer: UI-core fails on ViewDataTableTest 'should display the export popover when clicking the export icon' (screenshot ViewDataTableTest_export_options). This PR caused it, as intended: the popover now opens with 'Flatten report' unticked for the non-flat Keywords report, so the 'Include dimensions separately' option is hidden. Verified locally: with and without the PR, only this one of the 26 ViewDataTableTest screenshots differs, and ReportExporting passes. Fix: copy tests/UI/expected-screenshots/ViewDataTableTest_export_options.png from this PR's UI-core CI artifact (processed-ui-screenshots) and commit it through Git LFS. It could not be done here: the CI artifact is not available (GitHub is not reachable), local rendering does not match CI (the local 6.x-dev image is 35090 bytes, sha256 9ee1f6e5..., while the committed CI image is 35699 bytes, LFS oid 574cb13e...), and git-lfs is not installed to commit a PNG correctly. PHPCS: the PR changes no PHP files.

… hierarchical report

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AltamashShaikh

Copy link
Copy Markdown
Contributor Author

Auto-fix agent: fixed checks broken by this PR (UI-core (0)).

UI-core failed on 2 screenshots. ViewDataTableTest_export_options is caused by this PR: by that step the spec has made the Keywords report hierarchical again (step 13), so the export popover now correctly opens with 'Flatten report' unchecked. Synced the CI screenshot (commit daf31eb). PeriodSelector_month_selected (478 px diff) is not related to this PR.

Changed:

  • tests/UI/expected-screenshots/ViewDataTableTest_export_options.png

Screenshots synced from CI, changed by this PR:

  • ViewDataTableTest_export_options.png: Export popover for the hierarchical (unflattened) Keywords report now opens with 'Flatten report' unchecked instead of checked; data/options otherwise unchanged.

Not caused by this PR, left alone: PeriodSelector 'should change the date when a date is clicked in month-period mode' (PeriodSelector_month_selected.png, 478 px diff): this PR only changes the export popover (ReportExport.ts, its tests and expected export files) and does not touch the period selector. The CI image and the repo image look the same (same month, same selection), so this is CI rendering noise. Re-run UI-core; if it keeps failing on 6.x-dev too, sync it in a separate screenshot-sync PR.

@AltamashShaikh

Copy link
Copy Markdown
Contributor Author

Auto-fix agent: the failing checks are not caused by this PR, so the agent leaves them and waits for a new commit.

UI-core failed on one screenshot: PeriodSelector 'should change the date when a date is clicked in month-period mode' (PeriodSelector_month_selected.png, 478 px differ). All 478 pixels are in the Sa/Su calendar columns (x 437-482, y 127-230): the weekend day numbers are rendered slightly lighter. Dates, selection and layout are the same, so this looks like a colour transition caught mid-render. This PR only changes the report export popover (ReportExport.ts + spec, CoreHome dist, ReportExportPopover UI spec/screenshot, export expected files) and touches no PeriodSelector, calendar or CSS code. Nothing changed.

What has to happen: PeriodSelector_month_selected.png (UI-core): flaky rendering difference not caused by this PR. Only the anti-aliasing/colour of the weekend day digits in the calendar differs, with no change in data or layout, and the PR does not touch the period selector. Re-run the UI-core job. If it keeps failing, it needs a separate fix or screenshot sync on 6.x-dev, not in this PR.

@AltamashShaikh
AltamashShaikh marked this pull request as ready for review December 1, 2026 18:18
@AltamashShaikh
AltamashShaikh requested a review from a team December 1, 2026 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

1 participant