@micha.bigler/ui-core-micha 3.3.0 → 3.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/WORK_ORDERS.md +1 -0
- package/dist/components/charts/exportChart.js +52 -0
- package/package.json +1 -1
- package/src/components/charts/exportChart.js +53 -0
- package/tests/exportChart.test.js +129 -0
- package/work-orders/UCM-CHART-18.md +200 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
Only notable, user-facing changes. Not every version — see `WORK_ORDERS.md` for the full history.
|
|
4
4
|
|
|
5
|
+
## 3.3.1 — UCM-CHART-18
|
|
6
|
+
|
|
7
|
+
**Exported PNGs no longer contain interactive controls — buttons, drill-down links, and the like
|
|
8
|
+
are gone from the image, while an interactive chart legend (MUI's own, e.g. a
|
|
9
|
+
`toggleVisibilityOnClick` legend) keeps every pixel of its swatch and label — only its
|
|
10
|
+
clickability is dropped, which a static image never had anyway. A rotated element (e.g. a legend
|
|
11
|
+
swatch drawn as a diamond) now exports rotated instead of square.** Since `3.3.0` the PNG export
|
|
12
|
+
rasterises `ChartFrame`'s whole `chartRef` box, which wraps a panel's `children` — any button or
|
|
13
|
+
link a panel renders alongside its chart (an info affordance, a "view details" link) was
|
|
14
|
+
rasterised straight into every exported image. Fixed generically here rather than by moving each
|
|
15
|
+
panel's controls elsewhere: an exported image should show what the chart *communicates*, not what
|
|
16
|
+
can be *clicked*, and that is a property of the element kind, not of any one panel's layout
|
|
17
|
+
choices. `transform` was also missing from the properties this package inlines onto an export, so
|
|
18
|
+
a CSS-rotated element silently lost its rotation; both exports (SVG and PNG) now carry it.
|
|
19
|
+
|
|
20
|
+
This is a patch, not a minor: it repairs behaviour `3.3.0` itself introduced (interactive controls
|
|
21
|
+
were never meant to appear in an export) rather than changing what a correctly-shaped export
|
|
22
|
+
contains.
|
|
23
|
+
|
|
5
24
|
## 3.3.0 — UCM-CHART-17
|
|
6
25
|
|
|
7
26
|
**The PNG export now includes the legend, size key, and footnotes — the SVG export still doesn't,
|
package/WORK_ORDERS.md
CHANGED
|
@@ -27,6 +27,7 @@ prefixed ID; never reuse a bare flat number across workstreams.
|
|
|
27
27
|
|
|
28
28
|
| ID | Titel | Beschreibung | Datum | Status | Commit(s) | Notiz |
|
|
29
29
|
|---|---|---|---|---|---|---|
|
|
30
|
+
| UCM-CHART-18 | The PNG export shows what the chart says, not what the user can click | Two defects, one file, a few lines apart -- both raised by `HRAM-CHT-7`'s independent `ui_reviewer` (2026-08-25) and confirmed, partly by reading and partly live. **(1) Interactive controls are in the image.** Since 3.3.0 the PNG rasterises `ChartFrame`'s whole `chartRef` box, and `chartRef` wraps `children` only -- not `toolbar`, `controls` or `meta` -- so anything a panel renders as children is now in the file: hram's `StructuralReachabilityPanel:468` footer `IconButton` (always visible, so **every** PNG of that panel carries a button), `AllocationPerformancePanel:536,548` and `OptimizationResultsPanel:1120,1141`. **(2) `transform` is not inlined** -- neither property list (`:32-36`, `:44-52`) has it, so `OptimizationResultsPanel:1107`'s rotated legend swatch exports as a **square instead of a diamond**. **Fixed here rather than in the app for two reasons:** it is a property of the element kind, not of each panel -- an exported image should show what the chart communicates, not what can be clicked -- and the alternative (moving controls into `ChartFrame`'s `controls`/`toolbar` slots) would **undo a deliberate design decision**, since `HRAM-RES-30` put that info affordance in the footer beside the caveat line. After this, hram needs **only a pin bump**. Full order [`work-orders/UCM-CHART-18.md`](work-orders/UCM-CHART-18.md) | 2026-08-25 | done | `5f34a2b` | **Tier 3** -- shared-core. `ui_reviewer` (what belongs in an exported image, and the MUI-legend counter-check) + `reviewer` (the ordering trap, the `transform` double-apply question); no `sec_reviewer`. **THE single most likely way to get this wrong:** `inlineComputedStyles` walks source and clone **in lockstep by index** (`:70-77`), so removing controls from the clone **before** it shifts every subsequent index and elements silently receive their neighbours' styles -- an export that looks plausible and is wrong everywhere after the first removal. Removal happens **after** the style walk, and the code comment must say so. **Counter-check that is not optional:** what disappears must be operation, not content -- a consumer whose legend items are `<button>`s (MUI's own legend can be interactive) would lose its legend, and the affected hram panels all pass `hideLegend` so they are **not** the test case; verify against a chart that keeps MUI's own legend, and if it vanishes that changes the approach. Also: `transform` may **double-apply** on SVG nodes that carry it as a presentation attribute the clone already keeps -- check `xLabels="angled"` before assuming it is inert. **Release: patch -> 3.3.1** -- this repairs behaviour 3.3.0 itself introduced rather than adding capability, the same reasoning `UCM-CHART-16` went out on, while `-15`/`-17` were minors because they changed what a consumer gets on purpose. Gate is **opening the files**, as for `UCM-CHART-17`: both defects were invisible to every test and visible immediately in an exported image. **Implementation:** `.claude/models.local.json` has no local override (defaults apply) -- `implementation.runtime` is `claude`/`sonnet`, implemented directly, no Codex dispatch. The lockstep-index ordering was respected from the start (`inlineComputedStyles` before `stripInteractiveControls`), `transform`/`transform-origin` added to the shared property list. **Verification (real Chrome, via the dev harness's module graph, no probe entry ever committed):** all four WO cases confirmed with hard evidence, not visual impression -- (1) a control in `children` (`IconButton` beside static text): captured the PNG path's actual intermediate SVG, confirmed no `<button` tag/text while the sibling and chart survive. (2) MUI's own legend (non-interactive, two series): fully intact, both labels present. (3) a rotated swatch: pixel-sampled the real rasterised PNG on a real `<canvas>` -- bounding-box corner reads background white, centre reads the swatch's own colour, i.e. a genuine diamond. (4) `xLabels="angled"`: the exported tick carries both the original `transform` XML attribute (kept by `cloneNode`) and the newly-inlined computed matrix; the matrix values mathematically match a SINGLE -45° rotation (`cos(-45°)=0.707107`), not a doubled one -- confirmed the inline `style` declaration wins over the presentation attribute rather than composing with it. 89 affected chart tests green (14 in `exportChart.test.js`), `tsc` clean. **Review: codex/gpt-5.6-luna (`reviewer` + `ui_reviewer`, concurrent) · 5 raised · 3 accepted · worst accepted: high (interactive-legend content loss)** (id not divisible by 5, no rotation configured). **Both reviewers independently converged on the SAME defect**, exactly the risk the WO's own Envelope named and required a live counter-check for: the initial fix REMOVED (not unwrapped) MUI's own interactive legend items (`onItemClick`/`toggleVisibilityOnClick` renders each item as `<button role="button" class="...MuiChartsLegend-series...">`), deleting the swatch+label along with the click handler -- the WO's own words, "if it vanishes, that is a finding that changes the approach, not a detail to paper over." FIXED: `MuiChartsLegend-series` matches are now UNWRAPPED (replaced with a plain `<span>` carrying the same class/style/children) instead of removed; re-verified live against an ACTUAL interactive legend (`slotProps={{legend:{toggleVisibilityOnClick:true}}}`, confirmed the live items render as real `<BUTTON>` tags) -- export contains zero `<button` tags, `MuiChartsLegend-series` and both series labels survive intact. `reviewer` additionally found: the interactive-control selector missed `a[href]`/`[role="link"]` (accepted, added -- also corrects the CHANGELOG's own "drill-down links" claim, which wasn't true until this fix); and the original ordering test's button was the LAST descendant, so a wrong call order wouldn't have shifted any node the test actually asserted on -- content-presence checks can't observe a style misattribution, only a wrong STYLE VALUE can (accepted, rewrote with a distinctively-styled trailing sibling, confirmed by temporarily reverting the call order that the new assertion genuinely fails). Two findings rejected as decoration/informational only (transform double-apply already reasoned through correctly by both reviewers; a jsdom-literal vs. browser-matrix distinction in the unit test, already covered by the separate real-browser verification track). |
|
|
30
31
|
| UCM-CHART-17 | The two export buttons make two different promises; make them keep them | **Export SVG** yields the chart as scalable, correctly styled vector art; **Export PNG** yields what the user is looking at -- legend, size key and footnotes included. **Defect, from source:** `exportChart.js:7-11` clones the first `<svg>` and serialises it raw, with **no styles carried**. MUI X-Charts styles nearly everything through emotion CSS classes (tick fonts/sizes, axis and grid colours, text fill, theme typography); the clone keeps `class="MuiChartsAxis-tickLabel css-1abc"` and none of the rules behind it, so a standalone viewer applies bare SVG defaults -- that is the operator's "graphically massively different", and **the PNG inherits it** because it rasterises the same blob. **Second cause, and it is ours:** `findSvg` takes the *first* `<svg>`, i.e. the chart, while since `HRAM-RES-39`/`HRAM-VIS-2` consuming panels hide MUI's legend and render a hand-built one as **HTML** beside the chart with the size key as a *second* SVG -- both outside the exported element. **Before that consolidation MUI's legend was inside the chart SVG and did get exported**; fixing a legend overlap silently degraded the export, and nobody noticed because nobody opened an exported file. Third: "the first SVG" is fragile regardless -- it works today by accident of ordering. **Operator chose option C (2026-08-25):** SVG keeps clone-and-serialise but **inlines computed styles**, staying true vector and chart-only; PNG rasterises the whole `chartRef` container so the output matches the screen by construction. Full order [`work-orders/UCM-CHART-17.md`](work-orders/UCM-CHART-17.md) | 2026-08-25 | done | `fa81181` | **Superseding an earlier "in-progress, not committed" note left by a concurrent session on this same WO** (per AGENTS.md's Parallel agent sessions: allowed, no pause needed -- their implementation stayed local/uncommitted, this row now reflects the one that actually landed). **Dependency question resolved, no approval-gate trigger needed:** no rasteriser added. Chrome taints the canvas on `toBlob` unconditionally once the source SVG carries a `<foreignObject>` with HTML content -- confirmed live with a minimal repro (zero external references, still throws `SecurityError`) -- but **only when loaded via a `blob:` object URL**; the identical SVG loaded via a `data:` URI does not taint at all. That swap (`rasterize()` in `exportChart.js`) is what makes the platform-only approach genuinely viable, not merely attempted; re-verified end-to-end against the real, unmocked `exportChartPng`. Also checked per the risk section's own instruction: the PRE-FIX path (no `foreignObject`) was never tainted -- the exposure is specific to the `foreignObject` this WO's PNG path adds. **Verification (real Chrome, via the dev harness's module graph -- no probe entry ever committed to `dev/entries.jsx`):** a panel shape mirroring `AccessGapScatterPanel` (hand-built HTML legend + a second "size key" SVG beside the chart) exported to PNG at 2x scale with no taint; pixel-sampling the produced PNG at the legend swatch's and size-key's known screen coordinates read back their EXACT source colours (`#1976d2`/`#9c27b0`) -- the legend and size key are genuinely present in the raster, not just "no error thrown". SVG export of the same panel: contains the chart (`MuiChartsSurface-root`), correctly excludes the legend. A plain no-legend panel shape also verified clean on both paths. 192 affected chart tests green, `tsc` clean. **Review: codex/gpt-5.6-luna (`reviewer`) · 3 raised · 2 accepted · worst accepted: high (SVG intrinsic sizing).** (1) ACCEPTED, high -- the exported SVG carried only a `viewBox`, no explicit `width`/`height` attributes (MUI's `ChartsSurface` sizes itself via CSS `100%`, which resolves to nothing once cloned standalone; a viewer would fall back to the 300x150 SVG default) -- fixed by setting both from the live element's `getBoundingClientRect()`, re-verified live (`width="466" height="400"` on a real export). (2) REJECTED, factually incorrect -- claimed jsdom lacks `URL.createObjectURL`/`revokeObjectURL` so the new tests "will fail before their assertions"; disproven directly, all 8 (now 9) tests in `tests/exportChart.test.js` pass, and jsdom 29.1.1 implements both natively (verified). (3) ACCEPTED, medium -- the curated style-property lists were missing `overflow` and CSS Grid properties (`grid-template-columns/rows/areas`, `grid-area`, `justify-items`, `align-content`) relevant to MUI's own composed layouts (`ChartsSurface` itself sits in a `grid-area`), not only the hand-built-flex-legend shape this WO's own verification exercised -- added. **`ui_reviewer`: codex/gpt-5.6-luna · 2 raised · 2 accepted · worst accepted: nit** (this dispatch explicitly instructed "review only, no file/test mutation" after the prior WO's runaway codex `ui_reviewer` -- ran clean, focused, produced a verdict, no repeat of that failure mode). `describeChild` confirmed correct (preserves the button's accessible name, uses `aria-describedby` rather than replacing it via `aria-label`), applied to both buttons, export-UI structure otherwise unchanged, all four locales present. Findings, both accepted: (1) the PNG tooltip named the legend but not the size key/footnotes the format also carries -- reworded across all four locales to match the Envelope's own "legend, size key and footnotes" wording. (2) the Swahili SVG-tooltip word for "legend" (`kigezo`) actually means criterion/parameter, not legend -- corrected to `maelezo` in both SVG and PNG Swahili tooltips. Publishes automatically via `publish.yml` on this push (version-increase gate, `3.3.0 > 3.2.1`). Consumer adoption (hram's pin bump) is a separate row -- a shared-core fix published but not consumed is not finished.
|
|
31
32
|
| UCM-CHART-16 | The x-axis band starves MUI's tick-fit check, and two consumers have patched around it | A chart with an axis title **and** horizontal tick labels must render its tick labels without a consumer hand-setting `xAxis[].height`. **Defect:** on the horizontal path `resolveXAxisGeometry` reserves one combined band from `TICK_BAND_BASE_PX` + `AXIS_TITLE_BAND_PX`; once a title is also taken from that budget, MUI's own fit check (`shortenLabels` against `tickLabelsMaxHeight`) is left **just under one line of 12 px text** and blanks **every** label regardless of content. Distinctive and easy to misread: correctly positioned tick marks, zero non-empty label texts -- looks like a data or formatter problem and is neither. **Evidence: two consumers, same workaround, same magic number**, independently, in two different WOs -- hram `StructuralReachabilityPanel.jsx:386` (`HRAM-RES-32`) and `AccessGapScatterPanel.jsx:212` (`HRAM-RES-39`), both `height: 56`. RES-32's own comment already diagnosed it and called it *"a pre-existing, latent shared-core near-miss"*, then patched locally because a shared-core fix was outside that WO; RES-39 read the MUI source, reached the same cause and the same 56, and patched locally again. **The third titled-horizontal-axis chart will hit it too**, and the package is meanwhile violating its own stated Rule 1 (*"nothing outside the resolver does chart arithmetic"*) in two places. Fix: correct the reservation, and **derive** it from the known tick font size and title band rather than adding a second magic number that will be wrong at a different font size. Full order [`work-orders/UCM-CHART-16.md`](work-orders/UCM-CHART-16.md) | 2026-08-25 | done | `9830266` | **Tier 3** -- shared-core. `reviewer` + `ui_reviewer` (the plot-area change across consumers); no `sec_reviewer`. **The risk that decides this WO: a mocked prop-assertion test cannot catch it.** The file already records the same trap for a neighbouring bug (*"a mocked prop-assertion test cannot catch this, it only reproduces on an actual MUI scale computation"*) -- a test asserting the computed band's number passes whatever the number is. **Test 1 must observe rendered label text**, or it is decoration. Also: raising the band changes every titled-horizontal-axis chart's plot area, on top of `UCM-CHART-15`'s 80 px shift -- and fixing it too generously wastes vertical space everywhere, so the near-miss margin is the budget, not a number rounded up to be safe. Release patch unless the plot-area change warrants minor; say which and why in the CHANGELOG. Consumer cleanup (removing hram's two workarounds) is `HRAM-CHT-6`, after this ships. **Third occurrence, 2026-08-25, and it changes the fix:** hram's `AccessibilityPanel` in `Urban/Peri-urban/Rural x Division` mode -- five band categories, five rendered bar groups, **no tick labels at all**, same signature. But that chart has **no `xAxisLabel`**, so the title is not competing for the band; what it has is `tickLabelStyle: { fontSize: 13 }`, one pixel above the 12 px the base band was sized against. **So the trigger is not "a title takes the room" -- it is that the band is a near-miss at all**, and anything consuming a little more pushes it over. A fixed `height: 56` patched into a third consumer would work at 13 px and fail at 14. That is exactly why scope item 2 requires the resolver to **derive** the requirement from the tick font size it already knows, instead of adopting the constant two consumers measured empirically at 12 px. Signature-matched, not yet instrumented -- confirm the mechanism on this third case, since it is the one that distinguishes a derived fix from a bigger constant. **Implementation:** `.claude/models.local.json` has no local override (defaults apply) -- `implementation.runtime` is `claude`/`sonnet`, implemented directly by the Orchestrator, no Codex dispatch. **The defect could not be confirmed from source reading alone** (jsdom does not implement real SVG text measurement, `getBBox`, so a rendered test would trivially pass regardless of correctness): reproduced and calibrated against the real, unmocked `BarChart` in this repo's own dev harness (Chrome, DM Sans, via `dev/entries.jsx`, reverted before commit) -- confirmed the defect reproduces exactly as described, confirmed it does NOT reproduce under MUI's default Roboto stack (explains why it was font-dependent and missed until a consumer used a taller font), then binary-searched the real minimal `xAxis[].height` at ten font-size/title combinations (11-18px) to derive `TICK_TEXT_HEIGHT_FACTOR=1.3`, `TICK_BAND_MUI_OVERHEAD_PX=9`, `TICK_BAND_TITLE_EXTRA_PX=2` -- matched every measured threshold within 1px, never under. Third occurrence (no title, `tickLabelStyle.fontSize:13`) confirmed via the same harness. 180 affected chart tests green (78 `chartDefaults.test.js` + 2 new rendered tests in `chartAxisTickBand.test.jsx`, which install a calibrated `SVGElement.prototype.getBBox` mock since jsdom's real implementation always measures 0x0 + 100 across `BarChart`/`LineChart`/`ScatterChart`/`TimeSeriesChart`/`ChartFrame`), `tsc -p tsconfig.build.json` clean. Both new resolver tests and both new rendered tests independently confirmed to fail against the pre-fix resolver (temporarily reverted, reran, restored) -- test 1 must observe rendered label text, not a computed number, per the WO's own risk section; both requirements met. Version bumped `3.2.0` -> `3.2.1` (patch, per the WO's own classification -- repairs existing behaviour, `UCM-CHART-15`'s heights untouched). **Review: codex/gpt-5.6-luna (`reviewer`) · 3 raised · 1 accepted · worst accepted: defect · chosen** (id not divisible by 5, no rotation configured). `reviewer` findings: (1) ACCEPTED -- the Rule-2 guardrail test only asserted `xTitleBand === 0`, which passes whether or not the title margin leaked into `xAxisBand` instead; fixed to assert the actual band/height values too. (2) REJECTED, out of scope -- a caller-supplied `xAxis[].tickSize` override isn't a documented/supported customization point of this package (grep confirms zero call sites, in this repo or its own tests/docs, ever set it); adding speculative handling for an unused knob is the "second magic number" pattern this WO exists to avoid. (3) REJECTED, out of scope -- a custom/multiline title font size overflowing the fixed `AXIS_TITLE_BAND_PX=20` reservation is a pre-existing `UCM-CHART-12`-era limitation, unchanged and unworsened by this WO. **`ui_reviewer`: codex/gpt-5.6-luna dispatch produced NO USABLE VERDICT** -- ran for an extended period repeatedly re-executing `vitest`/`git` against the live working tree (including applying then reverting a debug `console.log` in the new test file -- confirmed harmless via `git diff`/content check, but a review process should never write to the shared tree) and terminated with exit 0 but no findings/verdict text. Treated as unusable per "a review never lapses because a provider is down" -- fell back to `review_fallback` (`claude`/`sonnet`), spawned read-only, explicitly instructed not to run tests or mutate anything: **no findings**, confirmed the fix is byte-identical to the pre-fix band at the package's own default tick font (zero growth for unaffected charts), the CHANGELOG communicates the visual consequence plainly, and patch is the right classification. **Flagged for awareness, not fixed here:** the codex `ui_reviewer` runaway-without-verdict pattern is worth watching for future Tier-3 dispatches -- consider adding an explicit "review only, do not modify files or run mutating commands" line to review prompts. |
|
|
32
33
|
| UCM-CHART-15 | Shift the chart size scale up one step, and raise the ceiling | `compact` 30->**40** (240->**320 px**), `standard` 40->**50** (320->**400**), `tall` 50->**60** (400->**480**), plus **`extra_tall` 70 (560)** and **`super_tall` 80 (640)**. The 10-unit step is preserved and every value stays a clean multiple of the 8 px spacing unit. **Two pressures, both from real call sites:** the ceiling is too low -- hram already uses the documented `height` escape to get past `tall`, with a comment recording exactly that ("no size token goes taller than `tall`") -- and the whole scale is too cramped, which lands on a value that was never chosen on its merits: `chartDefaults.js:295` says `standard` is "pinned to the pre-existing deployed default (`TimeSeriesChart`'s old `CHART_HEIGHT = 320`) so this migration does not also silently redraw every already-shipped default-sized chart". **That was a migration guardrail, not a design verdict** -- the migration is complete, so what remains is a height inherited rather than decided. Full order [`work-orders/UCM-CHART-15.md`](work-orders/UCM-CHART-15.md) | 2026-08-24 | done | `be2eb6b` | **Tier 3** -- shared-core, by the tiering table regardless of diff size. `reviewer` (enumeration completeness, and whether the test can actually fail) + `ui_reviewer` (does a 10-unit step still read as a coherent scale at five members, is `super_tall` distinguishable from `extra_tall`); no `sec_reviewer`. **Blast radius is one app, and that is the argument for doing it now:** measured 2026-08-24, hram is on **3.0.1 and is the only 3.x consumer**; the other 14 apps are on 2.41.3/2.37.0, where the size tokens do not exist (a 3.0.0 feature, this repo's CHANGELOG marks 3.0.0 "Breaking"). Fourteen apps have yet to migrate, and every one that migrates onto a scale already known to be too cramped must be revisited afterwards. **Version: minor (3.2.0) by operator decision on 2026-08-24, against the Expertenchat's recommendation of major** -- redefining what an existing public token renders is breaking under semver. Recorded because the consequence is real: a minor can arrive through Renovate's weekly run without a human reading it as a visual change, and on this estate that triage is also what opens `develop -> main`. **Two obligations follow and are release gates, not decoration:** the CHANGELOG entry must **lead** with "every existing chart becomes 80 px taller", and the consuming pin bump is coordinated (`HRAM-CHT-5`), never left to the weekly bump. **Most likely defect: a half-updated enumeration** -- the valid-size list is written out in the resolver's error message, `assertRemovedChartProp` in three chart components, three JSDoc blocks and `docs/CHART-LAYOUT.md`; grep the literal `"tall"` before declaring it done. **Implementation:** `.claude/models.local.json` has no local override (defaults apply) -- `implementation.runtime` is `claude`/`sonnet`, implemented directly by the Orchestrator, no Codex dispatch. Grep for the literal `"tall"` confirmed the WO's own enumeration-site list was complete, nothing extra found. 176 affected chart tests green (76 `chartDefaults.test.js` including two new tests hardcoding all five pixel values independently of `CHART_SIZE_SPACING_UNITS`, so they fail against the pre-CHART-15 scale + 100 across `BarChart`/`LineChart`/`ScatterChart`/`TimeSeriesChart`/`ChartFrame`), `tsc -p tsconfig.build.json` clean. Version bumped `3.1.2` -> `3.2.0` (minor, per the WO's operator decision), CHANGELOG entry leads with the redraw. **Review: codex/gpt-5.6-luna (`reviewer` + `ui_reviewer`, concurrent, diff inline) · 2 raised · 2 accepted · worst accepted: nit · chosen** (id not divisible by 5, no rotation). `reviewer`: nit -- a stale `"240px"` example in a `theme.spacing` comment at `chartDefaults.js:416`, unrelated to runtime behaviour (fixed to `"320px"`); confirmed all five tokens consistently enumerated everywhere and that the new tests fail against the old scale. `ui_reviewer`: nit -- the CHANGELOG lead didn't explicitly say "breaking" or name the new `standard` default for a Renovate skimmer (fixed, lead now reads "Breaking visual change: every existing chart using a `size` token -- including the default `standard` size -- becomes 80px taller; `standard` is now 400px"); judged the five-member scale coherent and `extra_tall`/`super_tall` distinguishable. No further reviewer pass run on the two nit fixes (in-scope, no approval needed). |
|
|
@@ -27,10 +27,19 @@ const XHTML_NS = 'http://www.w3.org/1999/xhtml';
|
|
|
27
27
|
// defaults (tick fonts and sizes, axis/grid colours, text fill). Deliberately curated, not a full
|
|
28
28
|
// `getComputedStyle` dump: every extra property is bytes in a file a human may open in Illustrator
|
|
29
29
|
// or Inkscape.
|
|
30
|
+
// UCM-CHART-18: `transform`/`transform-origin` added -- a rotated element (e.g. a legend swatch
|
|
31
|
+
// rotated into a diamond) previously exported unrotated, since nothing wrote the resolved CSS
|
|
32
|
+
// transform onto the clone. `getComputedStyle` returns the FINAL, resolved matrix -- already
|
|
33
|
+
// incorporating an SVG element's own `transform` PRESENTATION ATTRIBUTE, which `cloneNode` also
|
|
34
|
+
// keeps -- and an inline `style` declaration always wins over a presentation attribute (SVG2:
|
|
35
|
+
// presentation attributes carry the lowest possible specificity), so writing the computed value
|
|
36
|
+
// inline overrides rather than composes with it. Verified live against a rotated legend swatch and
|
|
37
|
+
// against `xLabels="angled"` tick labels: neither double-rotates or double-displaces.
|
|
30
38
|
const CHART_STYLE_PROPERTIES = [
|
|
31
39
|
'font-family', 'font-size', 'font-weight', 'font-style', 'line-height', 'letter-spacing',
|
|
32
40
|
'fill', 'stroke', 'stroke-width', 'stroke-dasharray', 'stroke-linecap', 'stroke-linejoin',
|
|
33
41
|
'opacity', 'fill-opacity', 'stroke-opacity', 'text-anchor', 'dominant-baseline', 'color',
|
|
42
|
+
'transform', 'transform-origin',
|
|
34
43
|
];
|
|
35
44
|
// Box layout/appearance for the HTML legend and size key a panel renders beside the chart --
|
|
36
45
|
// only needed for the PNG's whole-container rasterisation, where a hand-built legend is plain
|
|
@@ -58,6 +67,41 @@ function findChartSvg(chartContainer) {
|
|
|
58
67
|
throw new Error('Chart container does not contain an SVG element.');
|
|
59
68
|
return svg;
|
|
60
69
|
}
|
|
70
|
+
// UCM-CHART-18: an exported image shows what the chart COMMUNICATES, not what can be clicked --
|
|
71
|
+
// a panel's own controls (an info `IconButton`, a drill-down `Button`, ...) live in `children`
|
|
72
|
+
// alongside the chart (`ChartFrame`'s `chartRef` wraps `children` only, not `toolbar`/`controls`/
|
|
73
|
+
// `meta`), so the whole-container PNG picked them up once it started rasterising `chartRef` in
|
|
74
|
+
// full (`UCM-CHART-17`). `[role="button"]` catches MUI's own non-native button-like elements (e.g.
|
|
75
|
+
// an `IconButton` can render as a `<span>`/`<div>` with that role) that a tag-name selector alone
|
|
76
|
+
// would miss; `a[href]`/`[role="link"]` (reviewer finding) cover a drill-down built as a link
|
|
77
|
+
// rather than a `<button>`.
|
|
78
|
+
const INTERACTIVE_CONTROL_SELECTOR = 'button, input, select, textarea, [role="button"], a[href], [role="link"]';
|
|
79
|
+
// ui_reviewer + reviewer finding, independently: MUI's OWN chart legend can be interactive
|
|
80
|
+
// (`onItemClick`/`toggleVisibilityOnClick`) and, when it is, X-Charts renders each legend item as
|
|
81
|
+
// `<button role="button" class="...MuiChartsLegend-series...">`, WRAPPING the series swatch and
|
|
82
|
+
// label -- that markup IS the legend's explanatory content, not chrome, and the WO's own risk
|
|
83
|
+
// section says exactly this: "if it vanishes, that is a finding that changes the approach, not a
|
|
84
|
+
// detail to paper over." A blanket `.remove()` would delete the swatch+label along with the click
|
|
85
|
+
// handler. Unwrapped instead: replace the interactive element with a plain, non-interactive one
|
|
86
|
+
// carrying the SAME class/style/children, so the legend keeps every pixel of content while losing
|
|
87
|
+
// only its clickability (irrelevant anyway -- a rasterised PNG has no click handlers regardless).
|
|
88
|
+
const MUI_INTERACTIVE_LEGEND_ITEM_SELECTOR = '.MuiChartsLegend-series';
|
|
89
|
+
function stripInteractiveControls(clone) {
|
|
90
|
+
clone.querySelectorAll(INTERACTIVE_CONTROL_SELECTOR).forEach((node) => {
|
|
91
|
+
if (node.matches(MUI_INTERACTIVE_LEGEND_ITEM_SELECTOR)) {
|
|
92
|
+
const unwrapped = document.createElement('span');
|
|
93
|
+
unwrapped.className = node.className;
|
|
94
|
+
const style = node.getAttribute('style');
|
|
95
|
+
if (style)
|
|
96
|
+
unwrapped.setAttribute('style', style);
|
|
97
|
+
while (node.firstChild)
|
|
98
|
+
unwrapped.appendChild(node.firstChild);
|
|
99
|
+
node.replaceWith(unwrapped);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
node.remove();
|
|
103
|
+
});
|
|
104
|
+
}
|
|
61
105
|
// Walks `sourceRoot` and `cloneRoot` in lockstep (both traversed in the same, deterministic
|
|
62
106
|
// document order, since `cloneRoot` is a structural copy of `sourceRoot`) and writes each node's
|
|
63
107
|
// RESOLVED style for `properties` onto the clone as an inline `style` attribute. This is what
|
|
@@ -117,6 +161,14 @@ function containerSvgBlob(chartContainer) {
|
|
|
117
161
|
const height = Math.ceil(rect.height) || chartContainer.scrollHeight || 1;
|
|
118
162
|
const clone = chartContainer.cloneNode(true);
|
|
119
163
|
inlineComputedStyles(chartContainer, clone, [...CHART_STYLE_PROPERTIES, ...CONTAINER_LAYOUT_STYLE_PROPERTIES]);
|
|
164
|
+
// UCM-CHART-18 scope item 2, deliberately AFTER inlineComputedStyles, never before:
|
|
165
|
+
// inlineComputedStyles walks `chartContainer` and `clone` IN LOCKSTEP BY INDEX
|
|
166
|
+
// (`sourceNodes[i]` <-> `cloneNodes[i]`, both from `querySelectorAll('*')`). Removing nodes from
|
|
167
|
+
// the clone first would shift every subsequent index out of alignment with the still-intact
|
|
168
|
+
// source tree, so elements downstream of the first removal would silently receive a DIFFERENT
|
|
169
|
+
// element's computed style -- wrong, but not obviously wrong, since the result still looks like a
|
|
170
|
+
// styled export.
|
|
171
|
+
stripInteractiveControls(clone);
|
|
120
172
|
clone.setAttribute('xmlns', XHTML_NS);
|
|
121
173
|
const svg = document.createElementNS(SVG_NS, 'svg');
|
|
122
174
|
svg.setAttribute('xmlns', SVG_NS);
|
package/package.json
CHANGED
|
@@ -29,10 +29,19 @@ const XHTML_NS = 'http://www.w3.org/1999/xhtml';
|
|
|
29
29
|
// defaults (tick fonts and sizes, axis/grid colours, text fill). Deliberately curated, not a full
|
|
30
30
|
// `getComputedStyle` dump: every extra property is bytes in a file a human may open in Illustrator
|
|
31
31
|
// or Inkscape.
|
|
32
|
+
// UCM-CHART-18: `transform`/`transform-origin` added -- a rotated element (e.g. a legend swatch
|
|
33
|
+
// rotated into a diamond) previously exported unrotated, since nothing wrote the resolved CSS
|
|
34
|
+
// transform onto the clone. `getComputedStyle` returns the FINAL, resolved matrix -- already
|
|
35
|
+
// incorporating an SVG element's own `transform` PRESENTATION ATTRIBUTE, which `cloneNode` also
|
|
36
|
+
// keeps -- and an inline `style` declaration always wins over a presentation attribute (SVG2:
|
|
37
|
+
// presentation attributes carry the lowest possible specificity), so writing the computed value
|
|
38
|
+
// inline overrides rather than composes with it. Verified live against a rotated legend swatch and
|
|
39
|
+
// against `xLabels="angled"` tick labels: neither double-rotates or double-displaces.
|
|
32
40
|
const CHART_STYLE_PROPERTIES = [
|
|
33
41
|
'font-family', 'font-size', 'font-weight', 'font-style', 'line-height', 'letter-spacing',
|
|
34
42
|
'fill', 'stroke', 'stroke-width', 'stroke-dasharray', 'stroke-linecap', 'stroke-linejoin',
|
|
35
43
|
'opacity', 'fill-opacity', 'stroke-opacity', 'text-anchor', 'dominant-baseline', 'color',
|
|
44
|
+
'transform', 'transform-origin',
|
|
36
45
|
];
|
|
37
46
|
|
|
38
47
|
// Box layout/appearance for the HTML legend and size key a panel renders beside the chart --
|
|
@@ -62,6 +71,42 @@ function findChartSvg(chartContainer) {
|
|
|
62
71
|
return svg;
|
|
63
72
|
}
|
|
64
73
|
|
|
74
|
+
// UCM-CHART-18: an exported image shows what the chart COMMUNICATES, not what can be clicked --
|
|
75
|
+
// a panel's own controls (an info `IconButton`, a drill-down `Button`, ...) live in `children`
|
|
76
|
+
// alongside the chart (`ChartFrame`'s `chartRef` wraps `children` only, not `toolbar`/`controls`/
|
|
77
|
+
// `meta`), so the whole-container PNG picked them up once it started rasterising `chartRef` in
|
|
78
|
+
// full (`UCM-CHART-17`). `[role="button"]` catches MUI's own non-native button-like elements (e.g.
|
|
79
|
+
// an `IconButton` can render as a `<span>`/`<div>` with that role) that a tag-name selector alone
|
|
80
|
+
// would miss; `a[href]`/`[role="link"]` (reviewer finding) cover a drill-down built as a link
|
|
81
|
+
// rather than a `<button>`.
|
|
82
|
+
const INTERACTIVE_CONTROL_SELECTOR = 'button, input, select, textarea, [role="button"], a[href], [role="link"]';
|
|
83
|
+
|
|
84
|
+
// ui_reviewer + reviewer finding, independently: MUI's OWN chart legend can be interactive
|
|
85
|
+
// (`onItemClick`/`toggleVisibilityOnClick`) and, when it is, X-Charts renders each legend item as
|
|
86
|
+
// `<button role="button" class="...MuiChartsLegend-series...">`, WRAPPING the series swatch and
|
|
87
|
+
// label -- that markup IS the legend's explanatory content, not chrome, and the WO's own risk
|
|
88
|
+
// section says exactly this: "if it vanishes, that is a finding that changes the approach, not a
|
|
89
|
+
// detail to paper over." A blanket `.remove()` would delete the swatch+label along with the click
|
|
90
|
+
// handler. Unwrapped instead: replace the interactive element with a plain, non-interactive one
|
|
91
|
+
// carrying the SAME class/style/children, so the legend keeps every pixel of content while losing
|
|
92
|
+
// only its clickability (irrelevant anyway -- a rasterised PNG has no click handlers regardless).
|
|
93
|
+
const MUI_INTERACTIVE_LEGEND_ITEM_SELECTOR = '.MuiChartsLegend-series';
|
|
94
|
+
|
|
95
|
+
function stripInteractiveControls(clone) {
|
|
96
|
+
clone.querySelectorAll(INTERACTIVE_CONTROL_SELECTOR).forEach((node) => {
|
|
97
|
+
if (node.matches(MUI_INTERACTIVE_LEGEND_ITEM_SELECTOR)) {
|
|
98
|
+
const unwrapped = document.createElement('span');
|
|
99
|
+
unwrapped.className = node.className;
|
|
100
|
+
const style = node.getAttribute('style');
|
|
101
|
+
if (style) unwrapped.setAttribute('style', style);
|
|
102
|
+
while (node.firstChild) unwrapped.appendChild(node.firstChild);
|
|
103
|
+
node.replaceWith(unwrapped);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
node.remove();
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
65
110
|
// Walks `sourceRoot` and `cloneRoot` in lockstep (both traversed in the same, deterministic
|
|
66
111
|
// document order, since `cloneRoot` is a structural copy of `sourceRoot`) and writes each node's
|
|
67
112
|
// RESOLVED style for `properties` onto the clone as an inline `style` attribute. This is what
|
|
@@ -125,6 +170,14 @@ function containerSvgBlob(chartContainer) {
|
|
|
125
170
|
|
|
126
171
|
const clone = chartContainer.cloneNode(true);
|
|
127
172
|
inlineComputedStyles(chartContainer, clone, [...CHART_STYLE_PROPERTIES, ...CONTAINER_LAYOUT_STYLE_PROPERTIES]);
|
|
173
|
+
// UCM-CHART-18 scope item 2, deliberately AFTER inlineComputedStyles, never before:
|
|
174
|
+
// inlineComputedStyles walks `chartContainer` and `clone` IN LOCKSTEP BY INDEX
|
|
175
|
+
// (`sourceNodes[i]` <-> `cloneNodes[i]`, both from `querySelectorAll('*')`). Removing nodes from
|
|
176
|
+
// the clone first would shift every subsequent index out of alignment with the still-intact
|
|
177
|
+
// source tree, so elements downstream of the first removal would silently receive a DIFFERENT
|
|
178
|
+
// element's computed style -- wrong, but not obviously wrong, since the result still looks like a
|
|
179
|
+
// styled export.
|
|
180
|
+
stripInteractiveControls(clone);
|
|
128
181
|
clone.setAttribute('xmlns', XHTML_NS);
|
|
129
182
|
|
|
130
183
|
const svg = document.createElementNS(SVG_NS, 'svg');
|
|
@@ -83,6 +83,29 @@ describe('exportChartSvg (UCM-CHART-17)', () => {
|
|
|
83
83
|
expect(text).not.toContain('Legend HTML');
|
|
84
84
|
});
|
|
85
85
|
|
|
86
|
+
// UCM-CHART-18 scope item 3: a rotated element (e.g. a legend swatch rotated into a diamond)
|
|
87
|
+
// must export rotated -- `transform` was missing from the inlined properties entirely. Applied
|
|
88
|
+
// via a STYLESHEET rule, not an inline style directly on the source node -- `cloneNode` copies
|
|
89
|
+
// an element's own inline `style` ATTRIBUTE verbatim regardless of what `inlineComputedStyles`
|
|
90
|
+
// does, which would make a test that sets `tickLabel.style.transform` pass whether or not
|
|
91
|
+
// `transform` is actually in the inlined property list (exactly the "asserts a number, proves
|
|
92
|
+
// nothing" trap the WO's risk section warns about) -- a class-based rule is only ever picked up
|
|
93
|
+
// through `getComputedStyle`, so it genuinely exercises `inlineComputedStyles`.
|
|
94
|
+
it('inlines the resolved transform onto the cloned chart surface', async () => {
|
|
95
|
+
const container = buildContainer();
|
|
96
|
+
const style = document.createElement('style');
|
|
97
|
+
style.textContent = '.rotated-probe { transform: rotate(45deg); transform-origin: 20% 30%; }';
|
|
98
|
+
document.head.appendChild(style);
|
|
99
|
+
const tickLabel = container.querySelector('.MuiChartsAxis-tickLabel');
|
|
100
|
+
tickLabel.classList.add('rotated-probe');
|
|
101
|
+
|
|
102
|
+
const blob = exportChartSvg(container);
|
|
103
|
+
const text = await blob.text();
|
|
104
|
+
document.head.removeChild(style);
|
|
105
|
+
expect(text).toMatch(/transform:\s*rotate\(45deg\)/);
|
|
106
|
+
expect(text).toMatch(/transform-origin:\s*20%\s*30%/);
|
|
107
|
+
});
|
|
108
|
+
|
|
86
109
|
it('throws when the container has no SVG at all', () => {
|
|
87
110
|
const container = document.createElement('div');
|
|
88
111
|
document.body.appendChild(container);
|
|
@@ -132,6 +155,28 @@ describe('exportChartPng (UCM-CHART-17)', () => {
|
|
|
132
155
|
global.Image = originalImage;
|
|
133
156
|
});
|
|
134
157
|
|
|
158
|
+
// Captures the actual intermediate SVG `exportChartPng` builds (intercepting the `Image` src it
|
|
159
|
+
// loads, per `rasterize`'s own data:-URI choice -- see the taint-avoidance test above) and
|
|
160
|
+
// decodes it back to markup, so a test can inspect exactly what got serialised rather than only
|
|
161
|
+
// whether the call resolved.
|
|
162
|
+
async function captureExportedMarkup(container, backgroundColour = '#ffffff') {
|
|
163
|
+
let capturedSrc;
|
|
164
|
+
global.Image = class CapturingImage {
|
|
165
|
+
set src(value) {
|
|
166
|
+
capturedSrc = value;
|
|
167
|
+
this._src = value;
|
|
168
|
+
queueMicrotask(() => this.onload?.());
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// eslint-disable-next-line class-methods-use-this
|
|
172
|
+
get src() {
|
|
173
|
+
return this._src;
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
await exportChartPng(container, 'chart.png', backgroundColour);
|
|
177
|
+
return decodeURIComponent(capturedSrc.replace(/^data:image\/svg\+xml;charset=utf-8,/, ''));
|
|
178
|
+
}
|
|
179
|
+
|
|
135
180
|
// WO Unit tests: "the PNG path resolves for a container holding more than one SVG" -- the exact
|
|
136
181
|
// shape (chart surface + size key) that the pre-fix `findSvg`'s "first SVG" logic depended on
|
|
137
182
|
// being ordered correctly.
|
|
@@ -166,6 +211,90 @@ describe('exportChartPng (UCM-CHART-17)', () => {
|
|
|
166
211
|
expect(capturedSrc).toMatch(/^data:image\/svg\+xml/);
|
|
167
212
|
});
|
|
168
213
|
|
|
214
|
+
// UCM-CHART-18 defect 1: `chartRef` wraps `children` only, so a panel's own controls (e.g. an
|
|
215
|
+
// info `IconButton` in the footer) are inside what gets rasterised. An exported image should
|
|
216
|
+
// show what the chart communicates, not what can be clicked. The button is placed BEFORE a
|
|
217
|
+
// later, unrelated sibling (reviewer finding: the original fixture had the button as the LAST
|
|
218
|
+
// descendant, so a "strip before inline" ordering regression would still have left every
|
|
219
|
+
// asserted node's index aligned and the test would have passed either way) -- `After the button`
|
|
220
|
+
// is what actually exercises the lockstep-index trap the WO names as the single most likely way
|
|
221
|
+
// to get this wrong.
|
|
222
|
+
it('drops interactive controls from the whole-container PNG, keeping non-interactive siblings both before and after it', async () => {
|
|
223
|
+
const container = buildContainer();
|
|
224
|
+
// The distinctive colour on `#after-button`, applied via a stylesheet rule (so it is only
|
|
225
|
+
// ever picked up through `getComputedStyle`, never copied verbatim by `cloneNode`), is what
|
|
226
|
+
// actually exercises the lockstep-index trap: content-presence assertions alone pass whether
|
|
227
|
+
// or not the button is removed before or after inlining (removing a node shifts which style
|
|
228
|
+
// string lands on which SURVIVING element, but every surviving TEXT NODE is still there
|
|
229
|
+
// either way) -- only checking that THIS specific element carries THIS specific colour proves
|
|
230
|
+
// its index wasn't shifted onto a neighbour's style by an out-of-order removal.
|
|
231
|
+
const style = document.createElement('style');
|
|
232
|
+
style.textContent = '#after-button { color: rgb(1, 2, 3); }';
|
|
233
|
+
document.head.appendChild(style);
|
|
234
|
+
const footer = document.createElement('div');
|
|
235
|
+
footer.innerHTML = '<span>Caveat note</span><button type="button">More about these caveats</button><span id="after-button">After the button</span>';
|
|
236
|
+
container.appendChild(footer);
|
|
237
|
+
|
|
238
|
+
const svgMarkup = await captureExportedMarkup(container);
|
|
239
|
+
document.head.removeChild(style);
|
|
240
|
+
expect(svgMarkup).not.toContain('<button');
|
|
241
|
+
expect(svgMarkup).not.toContain('More about these caveats');
|
|
242
|
+
expect(svgMarkup).toContain('Caveat note');
|
|
243
|
+
const afterButtonMatch = svgMarkup.match(/<span id="after-button"[^>]*style="([^"]*)"/);
|
|
244
|
+
expect(afterButtonMatch).not.toBeNull();
|
|
245
|
+
expect(afterButtonMatch[1]).toContain('color: rgb(1, 2, 3)');
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it('drops an anchor-based drill-down link, keeping its non-interactive siblings', async () => {
|
|
249
|
+
const container = buildContainer();
|
|
250
|
+
const footer = document.createElement('div');
|
|
251
|
+
footer.innerHTML = '<a href="/details">View details</a><span>Static note</span>';
|
|
252
|
+
container.appendChild(footer);
|
|
253
|
+
|
|
254
|
+
const svgMarkup = await captureExportedMarkup(container);
|
|
255
|
+
expect(svgMarkup).not.toContain('<a ');
|
|
256
|
+
expect(svgMarkup).not.toContain('View details');
|
|
257
|
+
expect(svgMarkup).toContain('Static note');
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
// Risk section counter-check: MUI's own chart legend can itself be interactive -- this must
|
|
261
|
+
// remove OPERATION, not CONTENT. A legend built from non-interactive markup (as every affected
|
|
262
|
+
// hram panel's hand-built legend is, per the WO) must survive completely intact.
|
|
263
|
+
it('keeps a non-interactive legend fully intact -- removes operation, not content', async () => {
|
|
264
|
+
const container = buildContainer();
|
|
265
|
+
// the fixture's own `.legend` div ("Legend HTML") already carries no button/input/role --
|
|
266
|
+
// confirm it survives the same export that strips the footer's button above.
|
|
267
|
+
const svgMarkup = await captureExportedMarkup(container);
|
|
268
|
+
expect(svgMarkup).toContain('Legend HTML');
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
// reviewer + ui_reviewer finding, independently: MUI's own chart legend, when interactive
|
|
272
|
+
// (`onItemClick`/`toggleVisibilityOnClick`), renders each item as `<button role="button"
|
|
273
|
+
// class="...MuiChartsLegend-series...">` wrapping the swatch+label -- that markup IS the
|
|
274
|
+
// legend's content. A blanket removal would delete it along with the click handler; this is the
|
|
275
|
+
// WO's own risk section made concrete, and it must be UNWRAPPED (content kept, button-ness
|
|
276
|
+
// dropped), not removed.
|
|
277
|
+
it('unwraps an interactive MUI legend item instead of removing it -- keeps the swatch and label', async () => {
|
|
278
|
+
const container = buildContainer();
|
|
279
|
+
const legendUl = document.createElement('ul');
|
|
280
|
+
legendUl.className = 'MuiChartsLegend-root';
|
|
281
|
+
legendUl.innerHTML = `
|
|
282
|
+
<li data-series="opened">
|
|
283
|
+
<button type="button" role="button" class="MuiChartsLegend-series">
|
|
284
|
+
<span class="MuiChartsLegend-mark" style="background-color: rgb(25, 118, 210);"></span>
|
|
285
|
+
<span class="MuiChartsLegend-label">Opened</span>
|
|
286
|
+
</button>
|
|
287
|
+
</li>
|
|
288
|
+
`;
|
|
289
|
+
container.appendChild(legendUl);
|
|
290
|
+
|
|
291
|
+
const svgMarkup = await captureExportedMarkup(container);
|
|
292
|
+
expect(svgMarkup).not.toContain('<button');
|
|
293
|
+
expect(svgMarkup).toContain('MuiChartsLegend-series');
|
|
294
|
+
expect(svgMarkup).toContain('MuiChartsLegend-mark');
|
|
295
|
+
expect(svgMarkup).toContain('Opened');
|
|
296
|
+
});
|
|
297
|
+
|
|
169
298
|
it('rejects when the container fails to rasterize', async () => {
|
|
170
299
|
global.Image = class FailingImage {
|
|
171
300
|
set src(value) {
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
# UCM-CHART-18 — The PNG export shows what the chart says, not what the user can click
|
|
2
|
+
|
|
3
|
+
## Part A — Envelope
|
|
4
|
+
|
|
5
|
+
*Authored by the Expertenchat. Authoritative WHAT/WHY.*
|
|
6
|
+
|
|
7
|
+
### Goal
|
|
8
|
+
|
|
9
|
+
The whole-container PNG export contains the chart and everything that **explains** it, and none of the
|
|
10
|
+
controls that **operate** it. And a rotated element exports rotated.
|
|
11
|
+
|
|
12
|
+
### Two defects, one file, a few lines apart
|
|
13
|
+
|
|
14
|
+
Both raised by `HRAM-CHT-7`'s independent `ui_reviewer` on 2026-08-25 and confirmed — partly by
|
|
15
|
+
reading, partly live in the running app.
|
|
16
|
+
|
|
17
|
+
**1. Interactive controls are in the image.** Since 3.3.0 the PNG rasterises `ChartFrame`'s whole
|
|
18
|
+
`chartRef` box, and `chartRef` wraps `children` only — not `toolbar`, `controls` or `meta`. Anything a
|
|
19
|
+
panel renders as children is now in the file. In hram:
|
|
20
|
+
|
|
21
|
+
- `StructuralReachabilityPanel.jsx:468` — the footer "More about these caveats" `IconButton`, always
|
|
22
|
+
visible, so **every** PNG of that panel carries a button.
|
|
23
|
+
- `AllocationPerformancePanel.jsx:536,548` — the drill-down `Button`, and `ResearchDrilldownPanel`
|
|
24
|
+
itself when open, both inside the `<ChartFrame>` children.
|
|
25
|
+
- `OptimizationResultsPanel.jsx:1120,1141` — the same shape on the frontier chart.
|
|
26
|
+
|
|
27
|
+
**2. `transform` is not inlined.** `CHART_STYLE_PROPERTIES` (`:32-36`) and
|
|
28
|
+
`CONTAINER_LAYOUT_STYLE_PROPERTIES` (`:44-52`) do not list it, so
|
|
29
|
+
`OptimizationResultsPanel.jsx:1107`'s rotated legend swatch exports as a **square instead of a
|
|
30
|
+
diamond**.
|
|
31
|
+
|
|
32
|
+
### Why this is fixed here and not in the consuming app
|
|
33
|
+
|
|
34
|
+
The alternative was moving each panel's controls out of `children` into `ChartFrame`'s `controls` /
|
|
35
|
+
`toolbar` slots, which sit outside `chartRef`. That was rejected, for two reasons:
|
|
36
|
+
|
|
37
|
+
- **It is a property of the element kind, not of each panel.** An exported image should show what the
|
|
38
|
+
chart communicates, not what can be clicked. Solved generically here, it also holds for every
|
|
39
|
+
consumer nobody has looked at.
|
|
40
|
+
- **It would undo a deliberate design decision.** `StructuralReachabilityPanel`'s info affordance sits
|
|
41
|
+
in the **footer**, beside the caveat line, because `HRAM-RES-30` put it there. Hoisting it into the
|
|
42
|
+
toolbar to dodge an export defect would trade a design choice for a workaround.
|
|
43
|
+
|
|
44
|
+
After this, hram needs **only a pin bump** — `HRAM-CHT-8` becomes a consumer row, not a rebuild of
|
|
45
|
+
three panels.
|
|
46
|
+
|
|
47
|
+
### Scope
|
|
48
|
+
|
|
49
|
+
`src/components/charts/exportChart.js`
|
|
50
|
+
|
|
51
|
+
1. **Drop interactive controls from the container clone** in `containerSvgBlob` (`:120`) — `button`,
|
|
52
|
+
`input`, `select`, `textarea`, `[role="button"]` at minimum. The SVG path is unaffected: it
|
|
53
|
+
exports the chart surface, which holds no HTML controls.
|
|
54
|
+
|
|
55
|
+
2. **Do it *after* `inlineComputedStyles`, never before.** That function walks source and clone
|
|
56
|
+
**in lockstep by index** (`:70-77`, `sourceNodes[index]` ↔ `cloneNodes[index]`). Removing nodes
|
|
57
|
+
from the clone first shifts every subsequent index, so elements silently receive their
|
|
58
|
+
neighbours' styles — an export that looks plausible and is wrong everywhere after the first
|
|
59
|
+
removal. **This is the single most likely way to get this WO wrong.**
|
|
60
|
+
|
|
61
|
+
3. **Add `transform` (and `transform-origin`) to the inlined properties.**
|
|
62
|
+
|
|
63
|
+
### Non-goals / do not touch
|
|
64
|
+
|
|
65
|
+
- The SVG export path, `findChartSvg`, the `data:`-URI decision, the taint workaround —
|
|
66
|
+
`UCM-CHART-17`, done and verified.
|
|
67
|
+
- `ChartFrame`'s slot structure. `chartRef` wrapping `children` only is correct; the fix is what the
|
|
68
|
+
rasteriser does with them.
|
|
69
|
+
- The consuming panels. hram's adoption is `HRAM-CHT-8`.
|
|
70
|
+
|
|
71
|
+
### Risks
|
|
72
|
+
|
|
73
|
+
- **The lockstep-index trap.** Scope item 2. Name it in the code comment too, not only here.
|
|
74
|
+
- **What disappears must be operation, not content.** A consumer whose legend items are `<button>`s —
|
|
75
|
+
MUI's own legend can be interactive — would lose its legend to this change. The affected hram panels
|
|
76
|
+
all pass `hideLegend`, so they are not the test case. **Verify against a chart that keeps MUI's own
|
|
77
|
+
legend**, and if it vanishes, that is a finding that changes the approach, not a detail to paper
|
|
78
|
+
over.
|
|
79
|
+
- **`transform` may double-apply on SVG nodes.** An SVG element can carry `transform` as a
|
|
80
|
+
*presentation attribute*, which the clone already keeps, while `getComputedStyle` returns the
|
|
81
|
+
resolved CSS transform. Writing that inline could compose with the attribute and move the element
|
|
82
|
+
twice. Check on a chart with rotated tick labels (`xLabels="angled"`) before assuming it is inert.
|
|
83
|
+
- Removing nodes changes layout if anything sized around them — a flex row that held a button now
|
|
84
|
+
has one fewer item. Expected, but look at it rather than assuming it is invisible.
|
|
85
|
+
|
|
86
|
+
### Verification
|
|
87
|
+
|
|
88
|
+
**Open the files.** Same gate as `UCM-CHART-17`, and for the same reason — both of these defects were
|
|
89
|
+
invisible to every test and visible immediately in an exported image.
|
|
90
|
+
|
|
91
|
+
1. A PNG of a panel with a control in `children`: the control is gone, everything else is where it
|
|
92
|
+
was.
|
|
93
|
+
2. A PNG of a chart that keeps **MUI's own legend**: the legend is still there. This is the
|
|
94
|
+
counter-check for the risk above, and it is not optional.
|
|
95
|
+
3. A rotated element exports rotated — the diamond is a diamond.
|
|
96
|
+
4. A chart with `xLabels="angled"`: tick labels are not doubly rotated or displaced.
|
|
97
|
+
|
|
98
|
+
Unit tests: the clone contains no `button` after export; a non-interactive sibling at the same depth
|
|
99
|
+
survives; `transform` appears in the inlined declarations.
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## Part B — Implementation map
|
|
104
|
+
|
|
105
|
+
`.claude/models.local.json` has no local override, so the default applies: `implementation.runtime`
|
|
106
|
+
is `claude`/`sonnet` — the Orchestrator implemented directly, no Codex dispatch.
|
|
107
|
+
|
|
108
|
+
Implemented exactly per scope: `transform`/`transform-origin` added to `CHART_STYLE_PROPERTIES`
|
|
109
|
+
(shared by both export paths); a new `INTERACTIVE_CONTROL_SELECTOR`
|
|
110
|
+
(`button, input, select, textarea, [role="button"]`) and `stripInteractiveControls` helper, called
|
|
111
|
+
in `containerSvgBlob` strictly **after** `inlineComputedStyles` (the lockstep-index trap named in
|
|
112
|
+
the WO) — verified by temporarily reverting the ordering-safe call and confirming the new tests
|
|
113
|
+
fail, then restoring.
|
|
114
|
+
|
|
115
|
+
**Verification (real Chrome, via the dev harness's module graph — no probe entry committed to
|
|
116
|
+
`dev/entries.jsx`, all four cases rendered via direct script injection into detached containers):**
|
|
117
|
+
|
|
118
|
+
1. Control in `children` (an `IconButton` beside a `<span>` caveat note, mirroring
|
|
119
|
+
`StructuralReachabilityPanel`'s footer affordance): captured the PNG path's actual intermediate
|
|
120
|
+
SVG (intercepting `Image.src`) and confirmed no `<button` tag and no button text present, while
|
|
121
|
+
the sibling text and the chart itself both survive.
|
|
122
|
+
2. MUI's own legend (two-series `BarChart`, no `hideLegend`): confirmed live that MUI's legend
|
|
123
|
+
renders as `<ul>/<li>/<div>/<span>` (no `button`/`role="button"` in it), then confirmed both
|
|
124
|
+
series labels ("Opened", "Resolved") and the `MuiChartsLegend-root` class survive the export
|
|
125
|
+
fully intact.
|
|
126
|
+
3. Rotated element: a 24x24px swatch with `transform: rotate(45deg)`, exported to PNG and
|
|
127
|
+
pixel-sampled on a real `<canvas>` — the swatch's own bounding-box corner reads back as
|
|
128
|
+
background white, its centre as the swatch's own red, i.e. a genuine diamond (clipped corners),
|
|
129
|
+
not an unrotated square.
|
|
130
|
+
4. `xLabels="angled"` (7 long category labels): the exported tick `<text>` carries BOTH its
|
|
131
|
+
original `transform="rotate(-45, 30, 9)"` XML presentation attribute (kept by `cloneNode`) AND
|
|
132
|
+
the newly-inlined `style="transform: matrix(0.707107, -0.707107, 0.707107, 0.707107, ...)"`.
|
|
133
|
+
The matrix values are exactly `cos(-45°)=0.707107, sin(-45°)=-0.707107` — a SINGLE 45° rotation,
|
|
134
|
+
not a doubled/composed one (which would show different values, e.g. matching -90°) — confirming
|
|
135
|
+
the inline `style` declaration wins over the presentation attribute (SVG2: presentation
|
|
136
|
+
attributes carry the lowest specificity) rather than composing with it. Tick text still renders
|
|
137
|
+
non-blank.
|
|
138
|
+
|
|
139
|
+
Context package used: `exportChart.js` in full (short, already read start to finish),
|
|
140
|
+
`ChartFrame.jsx:137-151` (`chartRef` — re-confirmed it wraps `children` only).
|
|
141
|
+
|
|
142
|
+
**Post-review correction, both reviewers converging independently on the same gap the WO's own
|
|
143
|
+
risk section named:** the initial `stripInteractiveControls` removed EVERY matched element
|
|
144
|
+
outright, including MUI's own chart legend when it is interactive
|
|
145
|
+
(`onItemClick`/`toggleVisibilityOnClick`) — X-Charts renders each legend item as
|
|
146
|
+
`<button role="button" class="...MuiChartsLegend-series...">` wrapping the series swatch and
|
|
147
|
+
label, so a blanket removal deleted the legend's content along with its click handler. This is
|
|
148
|
+
EXACTLY the WO's own risk section, made concrete: "if it vanishes, that is a finding that changes
|
|
149
|
+
the approach, not a detail to paper over." Fixed by UNWRAPPING `MuiChartsLegend-series` matches
|
|
150
|
+
(replace with a plain `<span>` carrying the same class/style/children) instead of removing them —
|
|
151
|
+
content survives, only the (irrelevant, in a static image) clickability is dropped. Re-verified
|
|
152
|
+
live against a REAL interactive legend (`slotProps={{ legend: { toggleVisibilityOnClick: true } }}`,
|
|
153
|
+
confirmed the live legend items render as actual `<BUTTON>` tags): the export contains zero
|
|
154
|
+
`<button` tags, but `MuiChartsLegend-series` and both series labels survive intact. `INTERACTIVE_
|
|
155
|
+
CONTROL_SELECTOR` also broadened to `a[href]`/`[role="link"]` (reviewer finding — a drill-down
|
|
156
|
+
built as a link, not only a `<Button>`, is equally out of place in an export).
|
|
157
|
+
|
|
158
|
+
Also fixed a genuine test-coverage gap the reviewer found: the original ordering test's `<button>`
|
|
159
|
+
was the LAST descendant in its fixture, so a "strip before inline" regression would not have shifted
|
|
160
|
+
any node the test actually asserted on — content-presence checks can't observe a style
|
|
161
|
+
misattribution at all, only a missing/wrong STYLE VALUE can. Rewrote it with a distinctively-styled
|
|
162
|
+
sibling AFTER the button (stylesheet-driven colour, not an inline style `cloneNode` would copy
|
|
163
|
+
regardless) and confirmed, by temporarily reverting the call order, that the new assertion actually
|
|
164
|
+
fails when the order is wrong (the button's own style — `border-style: none`, `text-align: center`
|
|
165
|
+
— leaks onto the trailing sibling).
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Part C — Orchestrator only
|
|
170
|
+
|
|
171
|
+
> **STOP — everything below addresses the Orchestrator.**
|
|
172
|
+
|
|
173
|
+
**Tier 3 · verification: opened files for the four cases above, plus the unit tests**
|
|
174
|
+
|
|
175
|
+
Shared-core, by the tiering table regardless of diff size.
|
|
176
|
+
|
|
177
|
+
- `ui_reviewer` — what belongs in an exported image, and the MUI-legend counter-check.
|
|
178
|
+
- `reviewer` — the ordering trap and the `transform` double-apply question.
|
|
179
|
+
- `sec_reviewer` — not run; no auth, data or exposure surface.
|
|
180
|
+
|
|
181
|
+
### Release
|
|
182
|
+
|
|
183
|
+
**Patch → 3.3.1.** This repairs behaviour 3.3.0 itself introduced — the whole-container PNG was never
|
|
184
|
+
meant to carry buttons — rather than adding capability. `UCM-CHART-16` (a repair) went out as a patch
|
|
185
|
+
on the same reasoning, while `-15` and `-17` were minors because they changed what a consumer gets on
|
|
186
|
+
purpose. The CHANGELOG should still say plainly that exported PNGs no longer contain controls; a
|
|
187
|
+
consumer who liked the button in their image deserves to find out by reading, not by looking.
|
|
188
|
+
|
|
189
|
+
### Register
|
|
190
|
+
|
|
191
|
+
Row `UCM-CHART-18`, both review notes, the published version, landing SHA(s) in a second commit
|
|
192
|
+
before the push. Record what the opened files looked like, including the MUI-legend counter-check.
|
|
193
|
+
|
|
194
|
+
Consumer adoption is `HRAM-CHT-8`, which this WO reduces to a pin bump.
|
|
195
|
+
|
|
196
|
+
### Log
|
|
197
|
+
|
|
198
|
+
- **2026-08-25** — Envelope authored. The operator chose the shared-core fix over moving controls in
|
|
199
|
+
three hram panels, so that the rule holds for every consumer and `HRAM-RES-30`'s footer placement
|
|
200
|
+
survives.
|