fix: stretch the root only for container-sized charts - #1554
Merged
Conversation
.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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
.chart-wrapper.fit-xsizes itself withwidth: 100%, but the.vega-embedroot isinline-block— shrink-to-fit — so the percentage resolved to 0 and"width": "container"charts rendered 0px wide. The autosize listener now marks the root withfit-x/fit-ytoo, and.vega-embed.fit-xbecomes 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 /
widthsignal = 38 / 0 / 0 / 0 to 876 / 838 / 838 / 794. Fixed-size charts are byte-identical tomainacross 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.