mirror of
https://github.com/umami-software/umami.git
synced 2026-05-30 06:47:25 +00:00
clip the canvas wrapper to suppress first-paint overflow
Address Greptile P2 review on PR #4260. Before Chart.js' first ResizeObserver callback fires the canvas keeps its HTML5 default size of 300x150. With position: absolute that no longer pushes any ancestor's intrinsic size, but on a wrapper narrower than 300px the canvas can still poke past the wrapper for one frame before Chart.js catches up. Adding overflow: hidden to the relative wrapper clips that transient overflow and is the pattern Chart.js' own docs recommend for responsive charts inside flex / grid layouts. No steady-state behaviour change because the canvas is already sized to the wrapper once Chart.js takes over; the React tooltip lives outside this wrapper so it remains visible.
This commit is contained in:
@@ -133,7 +133,7 @@ export function Chart({
|
||||
wrapper sizes purely from its parent (width: 100%, height: 100%)
|
||||
and Chart.js' ResizeObserver picks up viewport changes.
|
||||
*/}
|
||||
<div style={{ position: 'relative', width: '100%', height: '100%' }}>
|
||||
<div style={{ position: 'relative', width: '100%', height: '100%', overflow: 'hidden' }}>
|
||||
<canvas ref={canvas} style={{ position: 'absolute', top: 0, left: 0 }} />
|
||||
</div>
|
||||
</Box>
|
||||
|
||||
Reference in New Issue
Block a user