Skip to content

fix: stretch the root only for container-sized charts - #1554

Merged
domoritz merged 2 commits into
mainfrom
fix/container-sizing
Aug 14, 2026
Merged

fix: stretch the root only for container-sized charts#1554
domoritz merged 2 commits into
mainfrom
fix/container-sizing

Conversation

@domoritz

@domoritz domoritz commented Aug 12, 2026

Copy link
Copy Markdown
Member

.chart-wrapper.fit-x sizes itself with width: 100%, but the .vega-embed root is inline-block — shrink-to-fit — so the percentage resolved to 0 and "width": "container" charts rendered 0px wide. The autosize listener now marks the root with fit-x / fit-y too, and .vega-embed.fit-x becomes a full-width block. Only container-sized charts stretch the root, so fixed-size charts keep their shrink-to-fit root and their actions menu position.

In an 876px parent, a container-sized chart goes from root / wrapper / canvas / width signal = 38 / 0 / 0 / 0 to 876 / 838 / 838 / 794. Fixed-size charts are byte-identical to main across block, flex, grid, and centered parents, with and without actions.

Closes #1066 — same bug, different route, with thanks to @mattijn for diagnosing it.

"height": "container" is still broken and out of scope: percentage heights need a definite parent height, so it needs its own change.

domoritz and others added 2 commits August 11, 2026 23:24
.chart-wrapper.fit-x sizes itself with width: 100%, which only resolves
against a root with a definite width. The root is inline-block, so it is a
shrink-to-fit containing block and the percentage resolved to 0: charts with
"width": "container" rendered 0px wide, and because containerSize()[0]
returned a finite 0, Vega-Lite's fallback never fired.

The autosize listener already marks the chart wrapper with fit-x/fit-y. It
now marks the root as well, so .vega-embed.fit-x can become a full-width
block. Only container-sized charts stretch the root, so fixed-size charts
keep their shrink-to-fit root and their actions menu stays at the chart's
edge. When actions are disabled there is no wrapper and both targets are the
same element, which also fixes container sizing for that case.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@domoritz
domoritz merged commit ea3e7b8 into main Aug 14, 2026
6 checks passed
@domoritz
domoritz deleted the fix/container-sizing branch August 14, 2026 18:24
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.

1 participant