Repository navigation
Fix chart overflow at narrow widths and smooth playground typing - #2
Merged
Merged
Conversation
The chart custom element is display:inline by default, so its clientWidth is 0 and every chart fell back to a fixed 640px width. At a full-width article that happened to fit; squeezed into the narrow playground pane it overflowed and left a horizontal scrollbar across the preview. Measure the block-level canvas container instead, reconcile against the chart's own width on resize, and coalesce resize bursts into one redraw per frame so a window drag no longer feels slow. A playground e2e asserts the preview never overflows sideways, at load and after a resize.
Re-mounting tears down and rebuilds every chart and diagram, so an edit that leaves the rendered output unchanged now skips the mount, and the debounce is a touch longer. Typing on a graphics-heavy document stays smooth.
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.
Follow-up to #1. Fixes the horizontal scrollbar that persisted on the playground preview and the sluggish feel.
Root cause
<alt-chart>is a custom element, so it isdisplay: inlineby default and reportsclientWidth: 0. The runtime'shost.clientWidth || 640therefore always took the 640px fallback: every chart has been a fixed 640px since the start. A full-width article column hid it; the narrow playground pane (~330px) exposed it as a scrollbar across the whole preview.Changes
No crate changes: chart sizing is a browser-runtime responsibility; the core only emits the component element and its accessible fallback table.
Verification
typecheck clean, eslint clean, 13 unit tests, build 45 KB, 15 e2e green (including the new overflow guard, which fails on the old code with a 284px overflow and passes on the fix).