Skip to content

fix: don't let a widget measure its box while the page is laid out for print - #5636

Merged
leaf-agent merged 1 commit into
mainfrom
fix/issue-5463
Nov 7, 2026
Merged

leaf-agent merged 1 commit into
mainfrom
fix/issue-5463

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

Print media opens a shut tab's panel, and a widget waiting in measure for the user to open that panel took the box paper laid out instead. The screen holds an undrawn widget at its stated height (layouts.css); paper holds no box. So an lf-chart in a shut tab fixed its height from its source's printed box, and kept that height once the tab opened on screen. measure now counts a box on paper as no box. It sets aside a paper delivery and observes the element afresh once the page is back on screen. That's needed because ResizeObserver reports only a change from the size it last delivered, so a screen box the same size as the paper one would otherwise never arrive.

This is the cause of the nightly corpus failure in #5463. pressable_paper_findings emulates print for a moment. On CI the alert review's two hourly charts (ar-canary-hours, ar-export-hours) measured in that window and drew at height 1, so Plot wrote <rect height="-59"> (1 − marginTop 20 − marginBottom 40) about seventy times. Those console errors failed the journey's teardown. Drawing those two chart specs with Plot at height 1 gives exactly those -59 bars. Locally, a probe showed both charts first receive a size while matchMedia("print") matches: 1040×540 and 1040×560, against stated heights of 200 and 220.

Verification
  • New test_a_chart_first_laid_out_on_paper_draws_at_its_stated_height: a chart with data-height="200" in a shut tab, laid out once on paper, draws at 180 (its source's height) on main and at 200 with this change.
  • tests/browser/widgets/test_charts.py and tests/smoke/test_plain_page.py pass, as do the print/paper-named tests across the browser files that emulate print.
  • tests/journeys/test_render_gate.py::test_the_layer_holds_its_whole_page_rules_on_the_corpus --run-nightly passes locally. It passed on main locally too: the CI-only window doesn't open on this host, even at 6× CPU throttle, so the nightly run after merge is the evidence for the journey itself.
  • pnpm run check and pnpm run test:runtime pass.

Rejected alternatives: drawing at the stated data-lf-height everywhere overrode an author's own CSS height (test_a_host_draws_each_widget_as_a_leaf_page_does). Drawing at the stated height only on paper resized the box inside its own ResizeObserver delivery and raised "ResizeObserver loop completed with undelivered notifications" on the corpus. Making the stated-height hold apply on paper as well would change what every x-height widget prints, so it's left alone.

skills/leaf/references/module-authoring.md says measure runs take "once the element has a box". That's still accurate, but it could now say "a box on screen". That edit is left out because it touches shipped agent instructions.

Closes #5463 — automated triage

…r print

Print media opens a shut tab's panel. A widget waiting in `measure` for the user
to open that panel took the box paper laid out instead. The screen holds an
undrawn widget at its stated height (layouts.css); paper holds no box, so an
lf-chart there fixed its height from its source's printed box and kept it once
the tab opened on screen. The corpus render gate emulates print for a moment in
`pressable_paper_findings`. On CI the alert review's two hourly charts measured
in that window and drew at height 1, so Plot wrote `<rect height="-59">`
(1 − marginTop 20 − marginBottom 40) about seventy times, and the console errors
failed the journey's teardown.

`measure` now counts a box on paper as no box. It sets aside a paper delivery
and observes the element afresh once the page is back on screen. Observing
afresh matters because ResizeObserver reports only a change from the size it
last delivered, so a screen box the same size as the paper one would never
arrive.

The new chart test fails before the change: a chart with data-height="200" in
a shut tab, laid out once on paper, drew at 180, its source's height. It draws
at 200 after. An earlier attempt that drew at the stated height on paper resized
the box inside its own ResizeObserver delivery and raised "ResizeObserver loop
completed with undelivered notifications" on the corpus.

Closes #5463
@leaf-agent
leaf-agent merged commit 1199218 into main Nov 7, 2026
6 checks passed
@leaf-agent
leaf-agent deleted the fix/issue-5463 branch November 7, 2026 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test_the_layer_holds_its_whole_page_rules_on_the_corpus: a corpus page sets a negative SVG rect height

1 participant