Repository navigation
Description
What problem would this solve?
Expanding a table (the ↗ button) targets 220 px per column and scrolls when the
surface is narrower — even when the surface is almost wide enough. At common
window/reading-width combinations this produces a marginal scroll of a few
dozen pixels with a mid-word clipped last column header, which reads as broken
rather than "scrollable by design".
Measured with the showcase "Project pulse" table (4 columns) at reading width
902 in a ~980 px window:
collapsed: viewport 725/725 — fits, no scroll ✓
expanded: viewport 882/958 — overflows by 76 px
sizer min-width: 880 px (4 × 220)
available for the sizer: ~804 px
So the expanded table misses the available width by ~9 %, and the user gets a
clipped header plus a scrollbar whose range is only 76 px. On macOS the overlay
scrollbar hides the strip, but the clipped column is the same.
The 220 px/column target is deliberate and test-locked
(testWideTableKeepsReadableColumnsAndExpandsIndependently asserts
minimumWidth == "1320px" for a 6-column expanded table), so this is filed as
a proposal rather than changed silently.
What would a great outcome feel like?
Expanding a table uses the free surface space first: columns grow beyond the
collapsed minimum only as far as the surface allows, and the table scrolls only
when even the collapsed minimum does not fit. No near-fit states with a few
pixels of scroll and a clipped header.
Possible approach
In layoutTable (Resources/Renderer/renderer.js), clamp the expanded width
to the available sizer width instead of always targeting columns × 220:
const available = surface.width - surface.leadingGutter; // what the sizer can occupy
const expandedWidth = Math.max(
baseTableWidth, // never narrower than collapsed
Math.min(available, columnCount * Math.max(220, readableColumnWidth))
);
const tableWidth = columnCount *
(expanded ? Math.max(220, readableColumnWidth) : readableColumnWidth); // todayi.e. sizer min-width = clamp(collapsedMin, available, columns × 220) when
expanded. Consequences:
- surface smaller than the collapsed minimum → scrolls (unchanged, correct);
- collapsed minimum fits but
columns × 220does not → expanded fills the
surface exactly, no scroll (the fixed case); - plenty of surface →
columns × 220as today.
The XCTest assertion "1320px" would move to the clamped value for its 900 px
test frame (≈ 864 px) or the test could use a wider frame; happy to adjust it
as part of the change.
Alternatives considered: a small tolerance threshold before enabling scroll
(simpler, but arbitrary and still clips at the boundary); leaving as-is
(consistent, but the marginal-scroll state keeps looking broken on classic
scrollbar platforms such as Windows).
Would you like to help?
I can implement the change with updated tests and re-measure across the width
sweep. (Found while building the experimental .NET port slice per
docs/PORTING.md; the same harness produced the measurements above. Related
but independent fixes: #25, #26.)
Project fit
- I considered offline behavior and document privacy (renderer-only change,
no network impact). - I searched existing issues and discussions.
Activity
ashtree74 commentedon Oct 6, 2026
Thank you for the measured proposal. The transition race and leading-gutter overflow from #25/#26 are fixed in #29 and PreviewMD 1.8 (12); those PRs have now been closed with links to the integration.
This proposal is a separate behavior change: the expanded-table width policy remains unchanged in 1.8. Keeping this issue open as an enhancement rather than treating it as resolved by the gutter fix.
A follow-up should decide the available-width clamp and cover near-fit surfaces, surfaces narrower than the collapsed minimum, wider surfaces, expand/collapse, and window/reading-width changes. That will let the policy change be reviewed independently with geometry regressions.