fix(xlsx): clip anchored charts/images/drawings to the grid's freeze panes - #6
Merged
eric8810 merged 1 commit intoJul 30, 2026
Merged
Conversation
…panes The chart, image, and drawing layers spanned the whole sheet surface with no clipping, so anchored objects scrolled past the grid origin painted over the column/row headers, the formula bar, and the host UI around the viewer. Each layer also carried its own copy of the frozen-extent, anchor-rect, and scroll-compensation math. Consolidate the geometry in grid-metrics.ts: createGridPaneLayout() derives the freeze-pane sub-boxes (main / frozen-rows / frozen-cols / frozen-corner) inside a grid-body layer inset past the headers, and places each object in the pane owning its anchor origin, compensating scroll only on the scrolling axes. The three layers become thin views that group items by pane; each pane clips its own objects the way Excel clips drawings per pane, with frozen panes stacked above the main pane to match the canvas paint order. Also align the public GRID_ROW_HEADER_WIDTH constant (40 -> 48) with the gutter XlsxGrid actually paints, so setChartRect/getChartRect coordinates agree with on-screen geometry; internal.ts is now the single source for both header metrics. Co-Authored-By: Claude Opus 5 (1M context) <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.
Problem
The XLSX chart, image, and drawing overlays spanned the whole sheet surface with no clipping. Anchored objects are positioned as
anchor position − scroll offset, so once the grid scrolled past an object's origin the offset went negative and the object painted over the column/row headers, the formula bar, and the host UI around the viewer:Fix
Clip anchored objects per freeze pane, the way Excel does.
components/grid-metrics.tsis the single source for anchored-object geometry:gridBodyLayerStyleinsets the overlay layers past the row/column headerscreateGridPaneLayout()splits the grid body into up to fouroverflow: hiddensub-panes (main/frozen-rows/frozen-cols/frozen-corner), assigns each object to the pane owning its anchor origin, and compensates scroll only on the scrolling axesXlsxChartOverlay/XlsxImageLayer/XlsxDrawingLayerbecome thin views over that module — their three hand-copied versions of the frozen-extent / anchor-rect / scroll-compensation math are deletedXlsxGridnow derives its header constants from the same module instead of local literalsAlso fixed
GRID_ROW_HEADER_WIDTHincomposables/internal.tssaid 40 whileXlsxGridactually paints a 48px gutter. The constant only feeds the public rect APIs (getChartRect/setChartRect/getImageRect/setImageRect), which were self-consistent but horizontally offset by 8px from on-screen geometry. Aligned to 48 withinternal.tsas the single source. Note: the exported constant's value changes, so hosts that manually compensated for the 8px skew would need to drop that compensation.Testing
tests/component/xlsx-anchored-panes.test.mjs: exact-coordinate assertions that freeze panes split into independently clipped panes, the frozen strip only follows horizontal scroll, and the main pane compensates both axesxlsx-menu-state.test.mjs, unrelated source-regex assertions), XLSX unit tests 29/29, workspace typecheck andvue-xlsxbuild cleanfinancial-model.xlsxP&L sheet andcharts-images.xlsx): charts, images, shapes, and form controls scroll with the cells and clip exactly at the grid-body edgeBefore
After
🤖 Generated with Claude Code