Skip to content

fix(super-editor): anchor header/footer caret to the line box after a tab - #3870

Open
PopaSerban wants to merge 3 commits into
superdoc:mainfrom
PopaSerban:fix/header-footer-caret-tab-anchoring
Open

fix(super-editor): anchor header/footer caret to the line box after a tab#3870
PopaSerban wants to merge 3 commits into
superdoc:mainfrom
PopaSerban:fix/header-footer-caret-tab-anchoring

Conversation

@PopaSerban

@PopaSerban PopaSerban commented Aug 5, 2026

Copy link
Copy Markdown

PR description:

Typing in a header or footer and pressing Tab renders the caret about 5.5px below its own line, hanging past the bottom of the row. Typing any character snaps it back, so the insertion point was always correct — only the caret's painted position between the Tab and the next keystroke was wrong.

This is the same symptom as #3507, which #3677 fixed for body text in June. That fix only touched DomSelectionGeometry.ts, so the header/footer caret path never got it.

Refs #3507, #3677

BeforeAfter
before.mov
after.mov

Review in cubic

Caret paths each decided independently whether an element's own box or its
enclosing line box is the caret box. A tab span and an empty SDT placeholder
are painted with a box that is deliberately not the line box, so reading the
element's own rect puts the caret off its row.

Move that rule into dom-observer/CaretLineAnchoring.ts and route the body
caret path through it, so a new caret path gets the rule by construction
rather than by remembering a comment.

No behavior change.
… tab

Typing in a header or footer and pressing Tab rendered the caret about 5.5px
below its own line, hanging past the bottom of the row. Typing any character
snapped it back, so the insertion point was always correct - only the caret's
painted position between the Tab and the next keystroke was wrong.

A painted tab span is deliberately height: line.lineHeight with
vertical-align: bottom (SD-3330) inside a .superdoc-line carrying
font-size: 0, so its own border box starts below the line top.
computeCaretRect resolves through #computeVisibleSurfaceCaretRect, which
falls back to the element's own rect for entries with no child text node.
A tab span is painted empty, so it took that branch and handed the tab's box
to the caret as both y and height.

Same symptom as superdoc#3507, which superdoc#3677 fixed for body text. That fix only
touched DomSelectionGeometry, so the header/footer path never got it.

Refs superdoc#3507, superdoc#3677
@PopaSerban
PopaSerban requested a review from a team as a code owner August 5, 2026 12:56
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 5 files

Re-trigger cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant