Skip to content

Plain tab-stop resolver mis-positions tabbed columns (wrapped/second lines, single-tab rows) #15

Description

@jmcopeland

Summary

Follow-up to #13 / #14. While validating the two-column signature block across several authoring styles, two pre-existing mis-positioning bugs surfaced in the plain (non-anchored) tab path. #14 fixes the left + right anchored case; these remain.

Version: @extend-ai/react-docx@0.8.0

Repro (4 labeled variants): https://github.com/jmcopeland/react-docx/raw/repro/tab-stop-column-wrap/repros/signature-block-variants.docx

Measured DOM x-positions (left text column at x≈388; left tab ≈772, right tab ≈1004):

Variant col-2 line 1 col-2 line 2 signature-line col-2 Name col-2
A — left+right tab stops (anchored, #14) 772 ✓ 772 ✓ 751 772 ✓
B — 2-cell table 704 ✓ 704 ✓ 704 ✓ 704 ✓
C — left-tab-only + line break 766 714 751 772
D — two paragraphs, tab-separated 766 714 751 772

Bug 1 — wrapped / second-line tab lands short (variants C, D)

When a line's pre-tab text is longer, the tab to the (same) left tab stop resolves to a different x than a shorter line's. Line 2 (On behalf of itself and its affiliates [tab] …) lands at 714, while line 1 (Client A [tab] …) lands at 766 for the same tab stop — the two column-2 lines don't align. Word aligns both at the stop.

Bug 2 — single-tab row (signature line) off by ~one position

The ____ [tab] ____ and Name: [tab] Name: rows put column 2 at 751/772, not consistently at the tab stop the party rows use, so the signature underline sits slightly left of its column.

Likely area

resolveNextTabStopPx(currentLineWidthPx, tabStopsPx) / the pretext line-layout tab handling: a tab should land on its explicit stop whenever the current line width is before that stop, independent of how much text precedes it on the line, and consistently across wrapped lines and single-tab paragraphs.

(These route through the plain tab path rather than the anchored center/right/left-right renderer, so #14 doesn't cover them.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions