Skip to content

fix(muya): size table columns to their content - #4952

Merged
Jocs merged 1 commit into
marktext:developfrom
Renakoni:fix/table-content-column-widths
Sep 3, 2026
Merged

Jocs merged 1 commit into
marktext:developfrom
Renakoni:fix/table-content-column-widths

Conversation

@Renakoni

Copy link
Copy Markdown
Contributor

Fixes #4894.

The cause

The equal-ish split was never a deliberate layout: .mu-table-cell-content carried a blanket min-width: 10em (inherited verbatim from the TS-rewrite migration, #4314). With the table's table-layout: auto, that floor inflates every column's minimum content width to ~160px — narrow columns (#, Short) waste 10em regardless of content, and a long column gets squashed into whatever remains. The issue's repro measures 186 / 186 / 328 px at a 700px editor width.

The fix

Drop the floor to 2em. Column widths become content-driven, exactly like GitHub's rendering in the issue: the same repro now measures 58 / 69 / 573 px — narrow columns hug their content, the long column takes the bulk.

Why keep any floor at all: a truly empty cell would collapse to a zero-width sliver that is hard to click into. 2em plus the existing cell padding keeps every empty cell a real caret target (a new empty 3-column table renders compact but fully editable — covered by the spec below).

On the "some might prefer the equal split" question from the issue thread: the old behavior was an accidental artifact of the floor, not a designed equal split, and the reporter's expectation (GitHub parity) is what table-layout: auto gives once the artifact is removed. If a configurable layout mode is ever wanted, it can build on this as the default.

Verification

  • New e2e spec (blocks/table-column-widths-4894.spec.ts, real Chromium): the repro's narrow columns render under 100/120px with the long column > 2× their sum (fails on the old CSS), and an empty cell stays a usable click-and-type target.
  • Table interaction neighborhood unaffected: drag bar, column toolbar, row/column menu, cross-cell selection, and rect clipboard e2e all pass with the narrower cells (19/19).
  • Full muya e2e (chromium): 244 passed; the two exceptions are this machine's known math-and-diagrams KaTeX click failure (identical on clean develop) and a @perf smoke that passes in isolation (49.8s, timing-sensitive under parallel load).
  • Stylelint on the changed file: no new findings (the 5 pre-existing ones are identical on develop).

niyo-oyin added a commit to niyo-oyin/marktext-ja that referenced this pull request Jul 30, 2026
Upstream PRs applied (all diff-reviewed, tests included and passing):
- marktext#4776: preserve ordered-list source markers — opening and saving no
  longer rewrites 1./1./1. to 1./2./3. (marktext#4772, silent doc mutation)
- marktext#4788: UNC/WSL paths become valid file:// authority URLs
  (file://server/share/…, not file:////…) so network images load
  (marktext#4577, marktext#4563)
- marktext#4952: table columns size to content (min-width 10em → 2em, marktext#4894)
- marktext#4773: malformed percent-escape in a clicked link no longer throws an
  unhandled URIError (marktext#4749)
- marktext#4873: Shift+digit/punctuation keybindings recordable and matchable
  again (patch-package fix for @hfelix/electron-localshortcut, marktext#4863)
- marktext#4910: sidebar icons match by extension first, so Dockerfile-Notes.md
  gets the markdown icon (marktext#4890)
- marktext#4317: restored windows are clamped to the target display's work area
  (multi-monitor / DPI, marktext#2928, marktext#1947)

Found while integrating marktext#4776: cloneStateTree shallow-copied meta, so
array-valued fields (order-list sourceMarkers, table aligns) stayed
SHARED between a getState() clone and the live document — mutating a
returned tree corrupted the document. Meta arrays are now copied, and
the clone walks an explicit work list instead of recursing, so
pathological nesting (600-level lists, marktext#4747) can no longer overflow
the call stack (10k-depth regression test).

Also: folder search debounces its per-keystroke ripgrep run (300ms,
Enter searches immediately, IME-composing keys ignored) (marktext#3556), and a
new undoFloor spec pins that undoing past the opened baseline never
empties the document (marktext#5028 — legacy-engine bug, does not reproduce on
@muyajs/core).

muya 1536/1536, desktop 783/783, lint/tsc/madge clean. PLANS.md gains a
prioritized backlog from the full 563-item issue/PR survey.
@Jocs

Jocs commented Sep 3, 2026

Copy link
Copy Markdown
Member

@Renakoni I took a little summer break for myself, so I haven’t been reviewing PRs recently. Thank you so much for your continued contributions!

@Jocs
Jocs merged commit ad6e84f into marktext:develop Sep 3, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Table column widths malformatted

2 participants